I have a custom validation directive that I had attributed to the form
<form myValidations>
app.directive('myValidations', function(){
return{
//require: 'ngModel', note its commented out
link: function(s,e,a,ctrl){//note the emphasis on the ctrl
}
}
});
now how would I grip this ctrl.$parsers if I don't have the 'require: ngModel' to do it for me.
could i find an element and then call its ng-model in some function to return an ng-model-controller? so that I can #$parsers from there?
Answering your question, you can call angular.element('elementSelector').controller('ngModel')
. It would return the ngModel the same way a require
would.
The question is: if you are creating a new directive, why not use its require feature? There are big chances that you are not using the right solution for your problem. So a bit more of code would give us the opportunity to further enlighten your question.