I am having this strange issue with only one of my views. The problem is that whenever I reload it by refreshing (Cmd + R / F5) the browser the whole app doesn't work until I change the route (manually or by clicking a link). The view resolves some data before it renders and I can verify that there are no request to the server whatsoever. Basically when I refresh I see all my scripts are loaded but my controller is never called (had a console.log in there) and I never get the view rendered.
Here is the state
$stateProvider.state( 'purchases', {
url: '/purchases',
views: {
"main": {
controller: 'PurchasesCtrl',
templateUrl: 'purchases/purchases.tpl.html'
}
},
resolve: {
purchases: function(PurchasesService, $rootScope) {
return PurchasesService.getPurchasesForUser($rootScope.user._id);
}
},
data:{ pageTitle: 'Purchases' }
});
$stateProvider.state( 'purchases_buy', {
url: '/purchases/buy/{itemId:[0-9a-fA-F]{24}}',
views: {
"main": {
controller: 'PurchasesBuyCtrl',
templateUrl: 'purchases/purchases_buy.tpl.html'
}
},
resolve:{
item: function(ItemsService, $stateParams){
return ItemsService.getItem($stateParams.itemId);
}
},
data:{ pageTitle: 'Buy' }
});
And here is the controller:
.controller( 'PurchasesCtrl', ['$scope', 'PurchasesService', '$stateParams', 'purchases', function ( $scope, PurchasesService, $stateParams, purchases ) {
$scope.purchases = purchases.data;
console.log("loaded");
$scope.predicates = ['firstName', 'lastName', 'birthDate', 'balance', 'email'];
$scope.selectedPredicate = $scope.predicates[0];
}])
.controller( 'PurchasesViewCtrl', ['$scope', 'PurchasesService', '$stateParams', 'purchase', function ( $scope, PurchasesService, $stateParams, purchase ) {
$scope.purchase = purchase.data;
}])
I have no idea why it keeps doing this but it is annoying and I would like to know what is the problem.