Я хочу вызвать функцию Controller
из Directive
, это для проверки. Но я немного запутался в том, как вызвать его из директивы, когда использую изолированную область видимости. Вот код директивы: -
App.directive('test',function(){
return{
require: "ngModel",
scope:{
a:"=",
b:"=",
c:'=',
d:'='
},
link: function(scope, element, attributes,modelVal )
{
modelVal.$validators.test= function(val)
{
return false;
//isolated scope values will make if condition true or false.
if(scope.a=="true"){
//I need to call a function of controller here. But how can
//i call that function from directive? this is my problem
}
}
scope.$watch("a", function()
{
modelVal.$validate();
});
}//end of link function;
}//end of return;
});//end of directive;
Function
в моем controller
, я думаю, мне не нужно писать controller code
. В моем html я называю эту директиву как:
<test a="1" b="2" c="3" d="4" ng-model="abc"></test>
Какие изменения мне нужно сделать в моем directive
, чтобы вызвать controller function
, который $scope.testFunction()
?