Jacksonkr
Jacksonkr

Reputation: 32217

ionic angular controller statement block only runs once

I have "coupons.html" and when I click a coupon item I'm taken to "single-coupon.html" where my SingleCouponCtrl is called:

.controller('SingleCouponCtrl', function($scope, $state, userService) {
  console.log("Fire Up Single Coupon Controller");
})

So when I start on "coupons.html" and click an item I see

Fire Up Single Coupon Controller

In the console but if I hit the back button and click an item again I don't get a repeat of "Fire Up Single Coupon Controller". Shouldn't I be seeing that again since I'm recalling the page? If not, how can I get my controller to run again?

I've tried using ng-init and $scope.init but it only accomplishes the same thing.

Upvotes: 0

Views: 208

Answers (1)

aorfevre
aorfevre

Reputation: 5064

Ionic cache a lot of things. I personnaly do the following on my routing JS ( cache: false, )

.state('camera',{
        url:"/camera",
        cache: false,
        controller:"CameraCtrl",
        templateUrl:'app/views/loading/index.html'

})

Upvotes: 2

Related Questions