How to load a method as soon as the page is loaded ? Angularjs

Asked

Viewed 85 times

-2

I have a method, carregarpagina(); that needs to be loaded as soon as the page is loaded. How do I do this on Angularjs.

1 answer

1


You can simply perform the function at the end of the file

$scope.carregarPagina = function() { //implementação do metodo } 
//...... seus outros métodos e atributos
$scope.carregarPagina();

Or use ngInit directive to assign a value when starting an attribute if necessary. https://docs.angularjs.org/api/ng/directive/ngInit

Browser other questions tagged

You are not signed in. Login or sign up in order to post.