import ngModule from '../module'; class TicketCard { constructor($http, $state) { this.$http = $http; this.$state = $state; this.ticket = null; } _getTicket() { let filter = { include: [ {relation: 'warehouse', scope: {fields: ['name']}}, {relation: 'agencyMode', scope: {fields: ['name']}}, { relation: 'client', scope: { fields: ['salesPersonFk', 'name'], include: { relation: 'salesPerson', fields: ['firstName', 'name'] } } }, { relation: 'tracking', scope: { fields: ['stateFk'], include: { relation: 'state', fields: ['name'] } } } ] }; let json = encodeURIComponent(JSON.stringify(filter)); this.$http.get(`/ticket/api/Tickets/${this.$state.params.id}?filter=${json}`) .then(res => { if (res.data) this.ticket = res.data; } ); } $onInit() { this._getTicket(); } reload() { this._getTicket(); } } TicketCard.$inject = ['$http', '$state']; ngModule.component('vnTicketCard', { template: require('./ticket-card.html'), controller: TicketCard });