import ngModule from '../module'; import './style.scss'; class Controller { constructor($scope, $http, $state) { this.$scope = $scope; this.$http = $http; this.$state = $state; this.order = {}; } setSummary() { this.$http.get(`/order/api/Orders/${this.order.id}/summary`).then(res => { if (res && res.data) this.summary = res.data; }); } get formattedAddress() { if (!this.summary) return; let address = this.summary.address; let province = address.province ? `(${address.province.name})` : ''; return `${address.street} - ${address.city} ${province}`; } $onChanges() { if (this.order && this.order.id) this.setSummary(); } showDescriptor(event, itemFk) { this.$scope.descriptor.itemFk = itemFk; this.$scope.descriptor.parent = event.target; this.$scope.descriptor.show(); } onDescriptorLoad() { this.$scope.popover.relocate(); } } Controller.$inject = ['$scope', '$http', '$state']; ngModule.component('vnOrderSummary', { template: require('./index.html'), controller: Controller, bindings: { order: '<' } });