#720 Refactorizar vn-submit para que permita desactivarlo

This commit is contained in:
Gerard 2018-11-16 13:43:24 +01:00
parent 1dc3c2c98f
commit 4fe76e8220
2 changed files with 24 additions and 17 deletions

View File

@ -1,7 +1,6 @@
<input
class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored"
type="submit"
class="*[className]*"
translate-attr="{value: '*[label]*'}"
value="*[label]*"
*[enabled]*>
translate-attr="{value: $ctrl.label}"
value="$ctrl.label">
</input>

View File

@ -1,16 +1,24 @@
import ngModule from '../../module';
import template from './submit.html';
directive.$inject = ['vnTemplate'];
export default function directive(vnTemplate) {
return {
restrict: 'E',
template: (_, $attrs) =>
vnTemplate.get(template, $attrs, {
label: 'Submit',
className: 'mdl-button mdl-js-button mdl-button--raised mdl-button--colored',
enabled: 'true'
})
};
export default class Controller {
constructor($element) {
this.$element = $element;
console.log($element);
this.input = $element[0].querySelector('input');
}
ngModule.directive('vnSubmit', directive);
set disabled(value) {
this.input.disabled = value;
}
}
Controller.$inject = ['$element'];
ngModule.component('vnSubmit', {
template: require('./submit.html'),
controller: Controller,
bindings: {
label: '@?',
disabled: '<?',
}
});