Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perform onload() in ionic

I want to load a function when a page loads.So how to use native javascript onload function in ionic.Here is 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 the this when page is loaded.How it possible in ionicframework?

like image 230
shellakkshellu Avatar asked Jun 12 '26 09:06

shellakkshellu


1 Answers

What about using the controller associated with that view?

.controller('YourCtrl', function($scope, $stateParams, Something) {
    alert("page loaded");
})
like image 83
Cris R Avatar answered Jun 14 '26 23:06

Cris R



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!