-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathperson-edit.component.ts
More file actions
73 lines (60 loc) · 1.62 KB
/
person-edit.component.ts
File metadata and controls
73 lines (60 loc) · 1.62 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import * as angular from 'angular';
export let PersonEditComponent = {
selector: 'personEdit',
template: `
<div class="col-md-8 col-md-offset-2" >
<form class="form-horizontal"
ng-submit="$ctrl.save()"
novalidate >
<div class="panel panel-default" >
<div class="panel-heading" >
Edit
<div class="pull-right" >
<button class="btn btn-primary btn-sm"
ladda="$ctrl.contacts.isSaving"
type="submit" >
<span >Save</span >
</button >
<button class="btn btn-danger btn-sm"
ladda="$ctrl.contacts.isDeleting"
ng-click="$ctrl.remove()" >Delete
</button >
</div >
<div class="clearfix" ></div >
</div >
<div class="panel-body" >
<ng-include src="'templates/form.html'" ></ng-include >
</div >
</div >
</form >
</div >
`,
bindings: {},
controller: class PersonCreateController {
public contacts = null;
public person = {};
private $state = null;
private $stateParams = null;
constructor($stateParams, $state, ContactService) {
this.$stateParams = $stateParams;
this.$state = $state;
this.contacts = ContactService;
this.person = this.contacts.getPerson(this.$stateParams.email);
}
save() {
this.contacts.updateContact(this.person)
.then(() => {
this.$state.go("list");
})
}
remove() {
this.contacts.removeContact(this.person)
.then(() => {
this.$state.go("list");
})
}
}
};
angular
.module('codecraft')
.component(PersonEditComponent.selector, PersonEditComponent);