Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 1 | /// <reference path="../../typings/index.d.ts"/> |
2 | import {Component, OnInit} from '@angular/core'; | ||||
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 3 | import {StyleConfig} from './config/style.config'; |
Matteo Scandolo | 40f8fa9 | 2016-12-07 09:21:35 -0800 | [diff] [blame^] | 4 | import {ISlice} from './interfaces/models.interface'; |
5 | import {SliceStore} from './services/stores/slice.store'; | ||||
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 6 | |
7 | @Component({ | ||||
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 8 | selector: 'xos-app', |
9 | template: require('./hello.html'), | ||||
Matteo Scandolo | 40f8fa9 | 2016-12-07 09:21:35 -0800 | [diff] [blame^] | 10 | providers: [SliceStore], |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 11 | }) |
Matteo Scandolo | 5e5c12b | 2016-12-05 16:17:52 -0800 | [diff] [blame] | 12 | export class HelloComponent implements OnInit { |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 13 | |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 14 | // declare class properties |
15 | public hello: string; | ||||
Matteo Scandolo | 40f8fa9 | 2016-12-07 09:21:35 -0800 | [diff] [blame^] | 16 | public slices: ISlice[]; |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 17 | |
Matteo Scandolo | 0f77c50 | 2016-12-06 16:46:00 -0800 | [diff] [blame] | 18 | constructor( |
Matteo Scandolo | 40f8fa9 | 2016-12-07 09:21:35 -0800 | [diff] [blame^] | 19 | private sliceStore: SliceStore |
Matteo Scandolo | 0f77c50 | 2016-12-06 16:46:00 -0800 | [diff] [blame] | 20 | ) { |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 21 | this.hello = `Hello ${StyleConfig.projectName}!`; |
Matteo Scandolo | 40f8fa9 | 2016-12-07 09:21:35 -0800 | [diff] [blame^] | 22 | this.slices = []; |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 23 | } |
24 | |||||
25 | ngOnInit() { | ||||
26 | console.log('on init'); | ||||
Matteo Scandolo | 40f8fa9 | 2016-12-07 09:21:35 -0800 | [diff] [blame^] | 27 | this.sliceStore.query() |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 28 | .subscribe( |
Matteo Scandolo | 40f8fa9 | 2016-12-07 09:21:35 -0800 | [diff] [blame^] | 29 | (slices: ISlice[]) => { |
30 | console.log(slices); | ||||
31 | this.slices = slices; | ||||
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 32 | }, |
Matteo Scandolo | 0f77c50 | 2016-12-06 16:46:00 -0800 | [diff] [blame] | 33 | err => { |
34 | console.warn(err); | ||||
35 | } | ||||
Matteo Scandolo | 5e5c12b | 2016-12-05 16:17:52 -0800 | [diff] [blame] | 36 | ); |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 37 | } |
38 | } |