forked from NathanWalker/angular-seed-advanced
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhome.component.ts
executable file
·42 lines (36 loc) · 1.09 KB
/
home.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// libs
import {OnInit, OnDestroy} from '@angular/core';
import {Store} from '@ngrx/store';
let instance = 0;
// app
import {FormComponent} from '../../frameworks/core/index';
import {NameListService} from '../../frameworks/app/index';
import {NavbarComponent} from '../app/navbar.component';
@FormComponent({
moduleId: module.id,
selector: 'sd-home',
templateUrl: 'home.component.html',
styleUrls: ['home.component.css'],
directives: [NavbarComponent],
})
export class HomeComponent implements OnInit, OnDestroy {
public newName: string = '';
private instanceNo = ++instance;
constructor(private store: Store<any>, public nameListService: NameListService) {
}
/*
* @param newname any text as input.
* @returns return false to prevent default form submit behavior to refresh the page.
*/
addName(): boolean {
this.nameListService.add(this.newName);
this.newName = '';
return false;
}
ngOnInit() {
console.log(`HomeComponent<${this.instanceNo}>.ngOnInit()`);
}
ngOnDestroy() {
console.log(`HomeComponent<${this.instanceNo}>.ngOnDestroy()`);
}
}