29 lines
960 B
JavaScript
29 lines
960 B
JavaScript
import {module as _module} from '../module';
|
|
import * as resolveFactory from '../lib/resolveDefaultComponents';
|
|
import * as normalizerFactory from '../lib/inputAttrsNormalizer';
|
|
import * as util from '../lib/util';
|
|
|
|
const _NAME = 'check';
|
|
export const NAME = util.getName(_NAME);
|
|
|
|
directive.$inject = [resolveFactory.NAME, normalizerFactory.NAME];
|
|
export function directive(resolve, normalizer) {
|
|
return {
|
|
restrict: 'E',
|
|
template: function(_, attrs) {
|
|
normalizer.normalize(attrs);
|
|
return resolve.getTemplate(_NAME, attrs);
|
|
},
|
|
link: function(scope, element, attrs) {
|
|
scope.$watch(attrs.model, () => {
|
|
let mdlField = element[0].firstChild.MaterialCheckbox;
|
|
if (mdlField)
|
|
mdlField.updateClasses_();
|
|
});
|
|
componentHandler.upgradeElement(element[0].firstChild);
|
|
}
|
|
};
|
|
}
|
|
|
|
_module.directive(NAME, directive);
|