Ng-click Vs click event
I am working on an angular js based website.
I have currently written about 5000 lines of code in angular js.
So I need to make some changes without touching my angular js.
I need something like this:
$(document).on('click','#buttonid',function(){
//performing some necessary task then call ng-click method
ngclickmethod();
});
HTML code:
<a ng-click="ngclickmethod()" id="buttonid">
Please advise how I can achieve this.
Many thanks
+3
source to share
1 answer
So it looks like you are trying to call an angular function outside of angular. Try it.
angular.element(document.getElementById('yourControllerElementID')).scope().ngclickmethod();
this will call the method you want. Make sure the id of the controller element is the controller that contains the ngclickmethod function.
+2
source to share