#720 Refactorizar vn-submit para que permita desactivarlo
This commit is contained in:
parent
1dc3c2c98f
commit
4fe76e8220
|
@ -1,7 +1,6 @@
|
||||||
<input
|
<input
|
||||||
|
class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored"
|
||||||
type="submit"
|
type="submit"
|
||||||
class="*[className]*"
|
translate-attr="{value: $ctrl.label}"
|
||||||
translate-attr="{value: '*[label]*'}"
|
value="$ctrl.label">
|
||||||
value="*[label]*"
|
|
||||||
*[enabled]*>
|
|
||||||
</input>
|
</input>
|
||||||
|
|
|
@ -1,16 +1,24 @@
|
||||||
import ngModule from '../../module';
|
import ngModule from '../../module';
|
||||||
import template from './submit.html';
|
|
||||||
|
|
||||||
directive.$inject = ['vnTemplate'];
|
export default class Controller {
|
||||||
export default function directive(vnTemplate) {
|
constructor($element) {
|
||||||
return {
|
this.$element = $element;
|
||||||
restrict: 'E',
|
console.log($element);
|
||||||
template: (_, $attrs) =>
|
this.input = $element[0].querySelector('input');
|
||||||
vnTemplate.get(template, $attrs, {
|
|
||||||
label: 'Submit',
|
|
||||||
className: 'mdl-button mdl-js-button mdl-button--raised mdl-button--colored',
|
|
||||||
enabled: 'true'
|
|
||||||
})
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
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: '<?',
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue