Reputation: 198
I used jQuery many times I am new to angular js.
I called a function on click event of a link. When i click on link it work fine and code is as below
<div data-ng-controller="myCtrl" >
<a id="clickBtn" data-ng-click="clickDetails()" ></a>
</div>
But when i trigger the click event programmatically on page load. This function not called "clickDetails". I am triggering click event using this code:
$(document).ready(function () {
$('#clickBtn').trigger('click');
});
Any hint or suggestion will be appreciated.
Thanks in advance
Upvotes: 0
Views: 418
Reputation: 1750
$timeout(function () {
angular.element(document.getElementById('clickBtn')).triggerHandler('click');
}, 0);
try it?
Upvotes: 1