function prMySelects() {
var ddo = {
restrict: 'E',
templateUrl: 'template.html',
require: '?ngModel',
scope: {
ngModel: '='
},
controller: prMySelectsController,
controllerAs: 'vm',
bindToController: true
};
return ddo;
}
function prMySelectsController($locale) {
...
}
I need do some checks inside directive controller and set ngModel.$setValidity('some', false), but getting ngModel is not defined
error. Injecting ngModel didn't help...
PS I know that I can access it in link
, but is it possible to reach ngModel controller in directive controller
?
This sort of functionality is best done inside the link function for a directive.
In this case, your are actually getting a hook into the ngModel controller and its not required that you actually specifiy it on the scope.