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
Post a Comment