-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathperson-create.component.ts
More file actions
54 lines (48 loc) · 1.26 KB
/
person-create.component.ts
File metadata and controls
54 lines (48 loc) · 1.26 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
import * as angular from 'angular';
export let PersonCreateComponent = {
selector: 'personCreate',
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">
Create
<div class="pull-right">
<button class="btn btn-primary btn-sm"
ladda="$ctrl.contacts.isSaving"
type="submit">Create
</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;
constructor($state, ContactService) {
this.$state = $state;
this.contacts = ContactService;
this.person = {};
}
save() {
console.log("createContact");
this.contacts.createContact(this.person)
.then(() => {
this.$state.go("list");
})
}
}
};
angular
.module('codecraft')
.component(PersonCreateComponent.selector, PersonCreateComponent);