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