Basically, I want to be able to pass in ng-model from a parent directive to a child directive. I could ju
ng-model functionality to a componentUse one-way < input for input and use the ngModelController API for output:
app.component("checkboxComponent", {
bindings: { ngModel: '<' },
require: { ngModelCtrl: 'ngModel' },
template: `
`,
controller: function() {
this.ngModelChange = () => {
this.ngModelCtrl.$setViewValue(this.ngModel);
};
}
})
The component uses one-way binding for input, and $setViewValue for output.
With this method, the ng-change works, and the component can be used as a form element:
For more information, see
angular.module("app",[])
.component("checkboxComponent", {
bindings: { ngModel: '<' },
require: { ngModelCtrl: 'ngModel' },
template: `
`,
controller: function() {
this.ngModelChange = () => {
this.ngModelCtrl.$setViewValue(this.ngModel);
};
}
})