Each time the controller runs I need to load a function init() but this is not working.
<script id="misviews.html" type="text/ng-template">
<ion-view>
<ion-tabs class="tabs-background-positive tabs-color-stable tabs-top tabs-striped" style="margin-bottom:20px;">
<ion-tab title="Lista" style="font-weight: bold;">
<ion-content lazy-scroll>
</ion-content>
</ion-tab>
<ion-tab title="Mapa" style="font-weight: bold;">
<ion-content class="map-container">
</ion-content>
</ion-tab>
</ion-tabs>
</ion-view>
</script>
This is my ion-view, with two tabs. I need a load a function whenever the driver, this first work, then allowed to run and does not update I need to start.
.controller('MisViewsCtrl', function($scope)){
$scope.init = function(){
alert("Hi");
}
$scope.init();
}
I tried this code, too ng-init="init();"
, and also data-ng-init="init();"
and none of it worked.
I could not explain well what I needed but fixed. I was checking and the term ng-init=""
is for data load and no function. I also found that ionic offers certain methods for the views. In those which I found was my mistake and it was not necessary to occupy the policies that I wanted to take. Here is the link and which served me.
$scope.$on('$ionicView.enter', function(){
});