-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathperson-edit.component.ts
More file actions
39 lines (34 loc) · 1022 Bytes
/
person-edit.component.ts
File metadata and controls
39 lines (34 loc) · 1022 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
38
39
import {Component, Inject} from "@angular/core";
import {Router, ActivatedRoute} from "@angular/router";
import {ContactService} from "../services/contact.service";
import {UIRouterStateParams, UIRouterState} from "../ajs-upgraded-providers";
@Component({
selector: 'personEdit',
templateUrl: 'app/components/person-modify.component.html'
})
export class PersonEditComponent {
public mode: string = 'Edit';
public person: any;
constructor(private contacts: ContactService,
private route: ActivatedRoute,
private router: Router) {
this.route.params.subscribe(params => {
console.log(params);
if (params['email']) {
this.person = this.contacts.getPerson(params['email']);
}
});
}
save() {
this.contacts.updateContact(this.person)
.then(() => {
this.router.navigate(['']);
})
}
remove() {
this.contacts.removeContact(this.person)
.then(() => {
this.router.navigate(['']);
})
}
}