I cant figure how to call a function from my directive using ng-click.
This is an example of my HTML:
<div>
<directive-name data="exemple">
<button class=btn btn-primary type="submit" ng-click="search()">
</directive-name>
</div>
This is an example of my javascript :
...
.directive('directiveName', ['exempleService', function(exempleService) {
function link(scope, element, attrs) {
scope.search = function() {
console.log("this is working")
};
};
return {
link: link,
restrict: 'E',
scope: {data:'=',
search:'&'}
}
}]);
Thanks in advance! :)