Issue with Controller Initialization after Redirect in Ionic App
I have encountered an issue where the controller is not initializing on the same page when I use $state.go or $location.href. In my Ionic app, I am using a sidemenu to pass category Id to the product page using a service. However, the data is not updating correspondingly to the current category Id. For example, when I click on 'aaa', I am successfully redirected to the product page and it alerts 1. But when I click on 'bbb' from the side menu, I get no alert. Interestingly, if I choose 'bbb' first, then it alerts 2 and vice versa.
Sidemenu Template
<ion-item nav-clear menu-close ng-click="allproductpage(1)">aaa</ion-item>
<ion-item nav-clear menu-close ng-click="allproductpage(2)">bbb</ion-item>
Sidemenu Controller
$scope.allproductpage= function(a){
angular.extend(inpsf.inps, {act_cat : a}) // inpsf is service
$location.path('/app/allproducts')
}
Product Page
.controller('AllproductsCtrl', function($scope,inpsf)
{
alert(inpsf.inps.act_cat)
})
P.S I have included
$ionicConfigProvider.views.maxCache(0);
in my .config file