1
|
import {Component} from '@angular/core';
|
2
|
import {Router} from '@angular/router';
|
3
|
import {Observable} from 'rxjs/Observable';
|
4
|
import {Location} from '@angular/common';
|
5
|
|
6
|
@Component({
|
7
|
selector: 'home',
|
8
|
template:`
|
9
|
|
10
|
<div class="container">
|
11
|
<div class="row">
|
12
|
<form>
|
13
|
<div class="col-lg-6">
|
14
|
<div class="input-group">
|
15
|
<input #term type="text" class="form-control col-xs-5" placeholder="Search for..." name="keyword" >
|
16
|
<span class="input-group-btn">
|
17
|
<button class="btn btn-default" type="submit" (click)="searchTerm(term.value)" >GO</button>
|
18
|
</span>
|
19
|
</div>
|
20
|
</div>
|
21
|
</form>
|
22
|
</div>
|
23
|
</div>
|
24
|
`
|
25
|
})
|
26
|
|
27
|
export class HomeComponent {
|
28
|
private start ;private end ;
|
29
|
|
30
|
constructor ( private _router: Router, private location: Location) {
|
31
|
this.start = new Date().getTime();
|
32
|
|
33
|
}
|
34
|
ngOnInit() {
|
35
|
|
36
|
this.end = new Date().getTime();
|
37
|
var time = this.end - this.start;
|
38
|
console.log('ngOnInit:Execution time: ' + time);
|
39
|
|
40
|
|
41
|
|
42
|
}
|
43
|
ngAfterContentInit() {
|
44
|
this.end = new Date().getTime();
|
45
|
var time = this.end - this.start;
|
46
|
console.log('ngAfterContentInit:Execution time: ' + time);
|
47
|
}
|
48
|
|
49
|
ngAfterViewChecked() {
|
50
|
|
51
|
this.end = new Date().getTime();
|
52
|
var time = this.end - this.start;
|
53
|
console.log('ngAfterViewChecked: Execution time: ' + time);
|
54
|
}
|
55
|
|
56
|
|
57
|
searchTerm(term: string) {
|
58
|
window.location.href="/search/find?keyword="+term;
|
59
|
}
|
60
|
}
|