-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAngular2Component.ts
More file actions
37 lines (29 loc) · 834 Bytes
/
Copy pathAngular2Component.ts
File metadata and controls
37 lines (29 loc) · 834 Bytes
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
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { StaffMember } from './staffMember';
import { StaffService } from '../core/services/staff.service';
@Component({
moduleId: module.id,
templateUrl: 'staff-list.component.html',
})
export class StaffListComponent implements OnInit {
staff: StaffMember[];
selectedStaffMember: StaffMember;
constructor(
private router: Router,
private staffService: StaffService
) { }
ngOnInit(): void {
this.getStaff();
}
getStaff(): void {
this.staffService.getStaff().then(staff => this.staff = staff);
}
onSelect(selected: StaffMember): void {
this.selectedStaffMember = selected;
this.gotoDetail();
}
gotoDetail(): void {
this.router.navigate(['/staff', this.selectedStaffMember.id]);
}
}