angularjs - How to call function on controller through directive? -


in directive have link calls function:

<a href="#" ng-click="resetfilter()">reset filter</a> 

js

app.directive('resetfilter', function () {   return {     templateurl: 'myfilter.html'   }}); 

i have defined resetfilter function in controller:

$scope.resetfilter = function () {     console.log('resetfilter'); } 

the problem function not firing? how can work?

simple directive has controller method , since directive has default scope. inherit parent scope default.

app.directive('resetfilter', function () { return { templateurl: 'myfilter.html' controller: function ($scope) {    $scope.resetfilter(); // call function defined in controller.  } }}); 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -