webfreaks
webfreaks

Reputation: 55

ng-click Vs click event

I am working on a website based on angular js.

Currently, I have written about 5000 line code in angular js.

So I have to make some changes without touching my angular js.

I want 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 can I achieve that.

Many Thanks

Upvotes: 3

Views: 2952

Answers (1)

prawn
prawn

Reputation: 2653

So it looks like you are trying to call an angular function outside of angular. Try this..

angular.element(document.getElementById('yourControllerElementID')).scope().ngclickmethod();

this will call the method you want. Be sure the controller element ID is the controller that contains the ngclickmethod function

Upvotes: 2

Related Questions