I am trying to use ng-click to call two functions, in the html for a directive. The first function, 'checkUrl', is in the directives controller, and is working fine.
The second function, 'findUrl', is in the main app controller, and is not being fired.
HTML:
<div class="status" ng-click="checkUrl()">
<b ng-click="checkUrl()">{{card.status}}</b>
</div>
<div ng-click="findUrl()" class="image">
<img ng-src={{card.image}} alt="">
</div>
I have a couple of questions:
1) Is this because the two controllers have different scopes, and one can't access the other?
2) How can I get the directives view/html to invoke the main controllers function?
directive's controller:
$scope.checkUrl = function() {
console.log("invoking checkUrl from the directive's controller.")
asnService.showUrl();
};
application controller:
$scope.findUrl = function() {
console.log("invoking findUrl from the app controller");
asnService.showUrl();
};
$scopeand usecontrollerAs. If you don't see an identifier before the function likesomething.findUrl()then it is an anti-pattern by today's Angular conventions.