import ngModule from '../../module'; export default class Controller { constructor($scope, $state) { this.$ = $scope; this.$state = $state; this.$stateParams = $state.params; } removeObservation(index) { this.$.watcher.setDirty(); this.$.model.remove(index); } cancel() { this.goToIndex(); } goToIndex() { this.$state.go('client.card.address.index'); } onResponse(response) { this.address.postalCode = response.code; } onSubmit() { this.$.watcher.check(); this.$.watcher.realSubmit() .then(() => this.$.model.save(true)) .then(() => { this.$.watcher.setPristine(); this.$.watcher.notifySaved(); this.card.reload(); this.goToIndex(); }); } } Controller.$inject = ['$scope', '$state']; ngModule.component('vnClientAddressEdit', { template: require('./index.html'), controller: Controller, require: { card: '^vnClientCard' } });