Created
February 6, 2016 00:37
-
-
Save christopherthielen/7e02962a9b6c9cb4d52e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // contact is a RevertableModel which is injected from the state's resolve data. | |
| export class EditContactController{ | |
| constructor($state, dialogService, Contacts, contact) { | |
| this.$state = $state; | |
| this.dialogService = dialogService; | |
| this.Contacts = Contacts; | |
| this.contact = contact.editableModel; | |
| this.clearDirty = () => contact.clearDirty(); | |
| } | |
| /** Ask for confirmation, then delete the contact, then go to the grandparent state ('contacts') */ | |
| remove(contact) { | |
| this.dialogService.confirm(`Delete contact: ${contact.name.first} ${contact.name.last}`) | |
| .then(() => this.Contacts.remove(contact)) | |
| .then(this.clearDirty) | |
| .then(() => this.$state.go("^.^")); | |
| } | |
| /** Save the contact, then go to the grandparent state ('contacts') */ | |
| save(contact) { | |
| this.Contacts.save(contact) | |
| .then(this.clearDirty) | |
| .then(() => this.$state.go("^", null, { reload: true })); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment