import ngModule from '../module'; class Controller { constructor($http, $state) { this.$http = $http; this.$state = $state; this.botanical = { itemFk: this.$state.params.id }; } _getBotanical() { let filter = { where: {itemFk: this.$state.params.id}, include: [{relation: 'genus'}, {relation: 'specie'}] }; this.$http.get(`/item/api/ItemBotanicals?filter=${JSON.stringify(filter)}`) .then(res => { if (res.data.length) this.botanical = res.data[0]; }); } $onInit() { this._getBotanical(); } } Controller.$inject = ['$http', '$state']; ngModule.component('vnItemBotanical', { template: require('./index.html'), controller: Controller });