i have a button that call a function on ng-click , my issue is : how can i get this button using the id and call the click event on my Angular run function, this is my code :
<button ng-click="myfunction()" id="myButton">Click !!</button>
app.run(['$rootScope',function($rootScope) {
// by default i want to click my button when the app is loaded
}]);
Note: i have a problem with "myfunction()" , this why i want to call it indirectly.
thanks in advance.
run()block executes if you are using routing or directive templates and the dom hasn't been compiled either and neither has controller been run. Why not fixmyfunction()here?myfunction()directly, probably this might help us suggesting a cleaner alternative? Using thengInitattribute, as @avim101 suggested, could be a solution - although it does not happen during app startup.