blob: fb517402f90df2ede306aa77c15112070210315a [file] [log] [blame]
Matteo Scandolo43ffb672016-12-02 14:49:58 -08001/// <reference path="../../typings/index.d.ts"/>
2import {Component, OnInit} from '@angular/core';
Matteo Scandolo43ffb672016-12-02 14:49:58 -08003import {StyleConfig} from './config/style.config';
Matteo Scandolo40f8fa92016-12-07 09:21:35 -08004import {ISlice} from './interfaces/models.interface';
5import {SliceStore} from './services/stores/slice.store';
Matteo Scandolod819c922016-12-02 14:06:14 -08006
7@Component({
Matteo Scandolo43ffb672016-12-02 14:49:58 -08008 selector: 'xos-app',
9 template: require('./hello.html'),
Matteo Scandolo40f8fa92016-12-07 09:21:35 -080010 providers: [SliceStore],
Matteo Scandolod819c922016-12-02 14:06:14 -080011})
Matteo Scandolo5e5c12b2016-12-05 16:17:52 -080012export class HelloComponent implements OnInit {
Matteo Scandolod819c922016-12-02 14:06:14 -080013
Matteo Scandolo43ffb672016-12-02 14:49:58 -080014 // declare class properties
15 public hello: string;
Matteo Scandolo40f8fa92016-12-07 09:21:35 -080016 public slices: ISlice[];
Matteo Scandolo43ffb672016-12-02 14:49:58 -080017
Matteo Scandolo0f77c502016-12-06 16:46:00 -080018 constructor(
Matteo Scandolo40f8fa92016-12-07 09:21:35 -080019 private sliceStore: SliceStore
Matteo Scandolo0f77c502016-12-06 16:46:00 -080020 ) {
Matteo Scandolo43ffb672016-12-02 14:49:58 -080021 this.hello = `Hello ${StyleConfig.projectName}!`;
Matteo Scandolo40f8fa92016-12-07 09:21:35 -080022 this.slices = [];
Matteo Scandolo43ffb672016-12-02 14:49:58 -080023 }
24
25 ngOnInit() {
26 console.log('on init');
Matteo Scandolo40f8fa92016-12-07 09:21:35 -080027 this.sliceStore.query()
Matteo Scandolo43ffb672016-12-02 14:49:58 -080028 .subscribe(
Matteo Scandolo40f8fa92016-12-07 09:21:35 -080029 (slices: ISlice[]) => {
30 console.log(slices);
31 this.slices = slices;
Matteo Scandolo43ffb672016-12-02 14:49:58 -080032 },
Matteo Scandolo0f77c502016-12-06 16:46:00 -080033 err => {
34 console.warn(err);
35 }
Matteo Scandolo5e5c12b2016-12-05 16:17:52 -080036 );
Matteo Scandolod819c922016-12-02 14:06:14 -080037 }
38}