import ngModule from '../module'; export default class Controller { constructor($scope, $state, $http, $translate, vnApp) { this.$ = $scope; this.$state = $state; this.$http = $http; this.$translate = $translate; this.vnApp = vnApp; this.client = { active: true }; } get postcodeSelection() { return this._postcodeSelection; } set postcodeSelection(selection) { this._postcodeSelection = selection; if (!selection) return; const town = selection.town; const province = town.province; const country = province.country; this.client.city = town.name; this.client.provinceFk = province.id; this.client.countryFk = country.id; } onResponse(response) { this.client.postcode = response.code; } onSubmit() { return this.$.watcher.submit().then( json => this.$state.go('client.card.basicData', {id: json.data.id}) ); } } Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp']; ngModule.component('vnClientCreate', { template: require('./index.html'), controller: Controller });