angularjs - Getting ngModelController of the input -
I need to access the input element ngModelController to check it is filthy or outdated.
I have been able to do it with the directive which captures the NGModal of the input of the data object associated with the element, it can be obtained from anywhere:
Replace: wrong, scope: false, is required: "ngmodel", link: function (scope, element, etters); app.directive ("input", [function () {return {restrict: "e" , CTRL) {element.data ('ngModelController', ctrls)}}}})I know that this instruction is used as a specialty Can be modified to make it not, so it is less coupled with the 'input' tags.
I use those saved controllers in the instructions that represent UI elements and they have
input elements in their markup. I do not use forms because those elements are either Dome should also work in context, and form indicates some limitations for the hierarchy, so I am using ngModelController so that some items required to verify the field are checked.
But is there any better way to get NGMDell controller of some input?
In my experience, angular already provides you in your directive where you can access the NGMDL controller Do the following, do the following:
app.directive ("randomDirective", function () {return ... ... requires: "ngModel", link: function (scope) , Element, ethers, CTLL) {var SomeInput = element.find ('the input'), NGModelCatineFor input = some input data (). $ NgModelController; // Now you can use ngModel controller for & lt; input & gt; Instructions}}}}
What is the best way to accomplish this achievement should be seen. I have not seen any better answer yet, You know that please ping me and tell me!).
Edit
A few other options, where something is similar:
element.find ('the input'). Controller ('ngmodel')
Comments
Post a Comment