salix/client/core/src/components/check/check.js

25 lines
792 B
JavaScript
Raw Normal View History

2018-02-10 15:18:01 +00:00
import ngModule from '../../module';
import template from './check.html';
import './style.css';
directive.$inject = ['vnTemplate'];
export default function directive(vnTemplate) {
return {
restrict: 'E',
template: (_, $attrs) =>
vnTemplate.getNormalized(template, $attrs, {
enabled: 'true',
className: 'mdl-checkbox__input'
}),
link: function(scope, element, attrs) {
scope.$watch(attrs.model, () => {
let mdlField = element[0].firstChild.MaterialCheckbox;
if (mdlField)
mdlField.updateClasses_();
});
componentHandler.upgradeElement(element[0].firstChild);
}
};
}
ngModule.directive('vnCheck', directive);