// libs import { Component, ElementRef, ViewChild, OnInit } from '@angular/core'; import { Store } from '@ngrx/store'; import { Observable } from 'rxjs/Observable'; // app import { RouterExtensions, Config } from '../../shared/core/index'; import { IAppState, getNames } from '../../shared/ngrx/index'; import * as nameList from '../../shared/sample/index'; @Component({ moduleId: module.id, selector: 'sd-home', templateUrl: 'home.component.html', styleUrls: ['home.component.css'] }) export class HomeComponent implements OnInit { public names$: Observable; public newName: string; constructor(private store: Store, public routerext: RouterExtensions) {} ngOnInit() { this.names$ = this.store.let(getNames); this.newName = ''; } /* * @param newname any text as input. * @returns return false to prevent default form submit behavior to refresh the page. */ addName(): boolean { this.store.dispatch(new nameList.AddAction(this.newName)); this.newName = ''; return false; } readAbout() { // Try this in the {N} app // {N} can use these animation options this.routerext.navigate(['/about'], { transition: { duration: 1000, name: 'slideTop', } }); } }