import ngModule from '../../module'; import Section from 'salix/components/section'; class Controller extends Section { constructor($element, $) { super($element, $); this.creditClassification = { started: this.$filter('date')(new Date(), 'yyyy-MM-dd HH:mm') }; } onSubmit() { if (this.$.form.$invalid) return this.vnApp.showError(this.$t('Some fields are invalid')); let query = `creditClassifications/createWithInsurance`; let data = this.creditClassification; data.clientFk = this.client.id; this.$http.post(query, data).then(res => { if (res.data) { this.card.reload(); this.$state.go('client.card.creditInsurance.index'); } }); } } Controller.$inject = ['$element', '$scope']; ngModule.component('vnClientCreditInsuranceCreate', { template: require('./index.html'), controller: Controller, require: { card: '^vnClientCard' }, bindings: { client: '<' } });