import ngModule from '../module';
import './style.scss';

class Controller {
    constructor($http) {
        this.$http = $http;
    }

    getSummary() {
        this.$http.get(`/item/api/Items/${this.item.id}/getSummary`).then(response => {
            this.summary = response.data;
        });
    }

    $onChanges() {
        if (this.item && this.item.id)
            this.getSummary();
    }
}

Controller.$inject = ['$http'];

ngModule.component('vnItemSummary', {
    template: require('./index.html'),
    controller: Controller,
    bindings: {
        item: '<',
    },
});