Closed sibelius closed 8 years ago
ng-model
is just fine, not sure what you mean migrate it to a component?
I've followed this tutorial - https://www.nadeau.tv/using-ngmodelcontroller-with-custom-directives/
If I want to implement a directive that provides a ng-model I need to implement NgModelController
like $formatters, $parsers, render, and so on
I'd like to know how can I achieve something similar using one-way data binding
Oh you mean require: '^ngModel'
as the controller for the component. Yeah you can use that as it just requires the controller. You will need to implement your own $parsers and $formatters for model -> view and then view -> model, I actually cover this in my course, code sample here: https://github.com/toddmotto/ultimate-angular-master-src/blob/master/parsers-formatters/content/js/directives/couponFormat.js
However, what you'll likely need is $setViewValue
and $render
: https://github.com/toddmotto/ultimate-angular-master-src/blob/master/setviewvalue-render/content/js/directives/HTMLEditor.js#L4-L15
so do you think ng-model is a good practice or should we removed it to use One-Way DataFlow and Events - https://github.com/toddmotto/angular-styleguide#one-way-dataflow-and-events?
How would you implement that with ng-model
?
Is ngModel pattern deprecated on ES6?
How can I migrate from a ng-model directive to a component?