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

swift - Button on Table View Cell connected to local function -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

c# - ajax - How to receive data both html and json from server? -