I want to call ng-click
function using console
. Is it possible?
<button class="btn btn-sm btn-block btn-green ng-binding" id="login-button"ng-click="onLoginClick($event)">Log In</button>
I want to call ng-click
function using console
. Is it possible?
<button class="btn btn-sm btn-block btn-green ng-binding" id="login-button"ng-click="onLoginClick($event)">Log In</button>
Share
Improve this question
edited May 1, 2018 at 8:55
Vega
28.7k28 gold badges120 silver badges145 bronze badges
asked May 1, 2018 at 5:44
user9380190user9380190
771 silver badge5 bronze badges
1
-
If not, then there are other ways to test
onLoginClick
, right? – Tim Biegeleisen Commented May 1, 2018 at 5:47
4 Answers
Reset to default 5You can try this:
angular.element('#login-button').triggerHandler('click');
this will work for sure.
You can use javascript getelementbyid as following:
document.getElementById("login-button").click();
The only way it es to my mind to do it is using jQuery to select the element (button) and then trigger the click:
$( "#login-button" ).trigger( "click" );
Try it and let us know if it works, here you are a JSFiddle: link
Yes. You can invoke/execute a function using window.function_name()
or function_name()