angularjs - call method from directive to controller -
i want call function in controller directive.
my directive
.directive('multecs', ['$http', function($http){ return{ restrict: 'a', replace:false, link: function(scope, elem, attr){ scope.addtoarray(); } } }]);
method in controller
$scope.addtoarray = function(){ console.log('method called'); }
try passing in function want call directive.
.directive('multecs', ['$http', function($http){ return{ restrict: 'a', replace:false, scope : { myfunctiontocall : '=' }, link: function(scope, elem, attr){ scope.myfunctiontocall(); } } }]);
Comments
Post a Comment