0
<a role="button" id="trigger" class="qui-button" ng-click="ctrl.openDialog(); ctrl.triggerClick();">Confirm Dialog</a>

I want to trigger this by pressing another button, i was using jquery to trigger the click event by:

function myFunction() {
  document.getElementById("trigger").click()
}

I trigger the click event, but ng-click event did not work.

How could i fix this problem?

evelyn
  • 45
  • 8
  • Possible duplicate of [How to trigger ng-click \[AngularJS\] programmatically](http://stackoverflow.com/questions/22447374/how-to-trigger-ng-click-angularjs-programmatically) – Jhecht Oct 26 '16 at 03:48
  • Try change ctrl => $ctrl, as in ng-click="$ctrl.openDialog();... – Mikkel Oct 26 '16 at 04:15

1 Answers1

1

Why don't you just have the other button with an ng-click equal to the same function?

Crhistian Ramirez
  • 1,066
  • 12
  • 20
  • This is the right solution. It's pointless and confusing to force dom manipulation into your code in order to trigger a click on an element to run some behavior. It will confuse future devs, this is what ng-click is for – William B Oct 26 '16 at 04:15