2017-01-31 13:13:06 +00:00
|
|
|
import {module as _module} from '../module';
|
2017-02-07 13:34:26 +00:00
|
|
|
import * as resolveFactory from '../lib/resolveDefaultComponents';
|
|
|
|
import * as normalizerFactory from '../lib/inputAttrsNormalizer';
|
|
|
|
import * as util from '../lib/util';
|
2017-01-31 13:13:06 +00:00
|
|
|
|
|
|
|
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);
|