window.angular && (function(angular) { 'use strict'; /** * * tableCheckbox Component * */ const controller = function($element) { // element ref needed to add indeterminate state let inputEl; /** * Callback when the input select value changes */ this.onSelectChange = () => { const checked = this.ngModel; this.emitChange({checked}); }; /** * onChanges Component lifecycle hook */ this.$onChanges = (onChangesObj) => { const indeterminateChange = onChangesObj.indeterminate; if (indeterminateChange && inputEl) { inputEl.prop('indeterminate', this.indeterminate); } }; /** * postLink Component lifecycle hook */ this.$postLink = () => { inputEl = $element.find('input'); }; }; /** * Component template */ const template = `
` /** * Register tableCheckbox component */ angular.module('app.common.components').component('tableCheckbox', { controller: ['$element', controller], template, bindings: {ngModel: '=', indeterminate: '<', emitChange: '&'} }) })(window.angular);