Do onload () in ionic
I want to load a function when the page is loaded. Since using the built-in onload javascript function in ionic.Here is a sample html page.
<ion-view title="Account" >
<ion-content class="has-header padding">
<h1>Account</h1>
<button id="bt">test</button>
</div>
</ion-content>
</ion-view>
here is my javascript file
function testload(){
alert("page loaded");
}
I want to load this on page load. How is this possible in an ion chamber?
+3
source to share
4 answers
You should probably check $ ionicPlatform if you want to execute some function after the device is ready
$ionicPlatform.ready([callback])
Or just loading the page ... in your controller, inject $ scope and listen for $ ionicView.loaded
app.controller('controller', function($scope) {
$scope.$on('$ionicView.loaded', function(event) {
});
});
+1
source to share