Here is a snippet of code from my first template studies.html:
<div class="feed-item">
<div class="feed-media" ng-repeat="study in studies">
<img src="{{study.image}}" class="feed-image">
<div class="feed-gradient-overlay"></div>
<a href="#/app/studies/{{study.nodeRef}}"><h4 class="feed-title">{{study.title}}</h4></a>
</div>
</div>
I get the studies data from my controller:
$rootScope.nodeId = $stateParams.studynodeRef;
Studies.all().then(function(payload) {
$scope.studies = payload;
$scope.study = $filter('filter')(payload, function(d) {
$scope.id = "" + $rootScope.nodeId;
if (d.nodeRef === $scope.id)
return d;
})[0];
});
The controller gets the data from the Studies service which asynchronously gets data from a json file. When you click on a study in study.html it takes you to href="#/app/studies/{{study.nodeRef}} which is represented by the overview.html file:
.state('app.study_collections', {
url: "/studies/:studynodeRef",
views: {
'menuContent': {
templateUrl: "templates/rubyonic/overview.html",
controller: 'AppCtrl',
reload: true
}
}
})
There is also the sidemenu file menu.html which loads a set of collections in the side menu which is present in all the templates. The collections point to a particular noderef depending on which study you clicked on. The nodeRef is extracted from the $stateparams of the url as seen on this line $rootScope.nodeId = $stateParams.studynodeRef;
Now the problem is when I go back and click on another study the collections on the side menu are not automatically updated on the overview.html page, they are updated when I refresh the page. Here is the snippet of code from the menu.html page which loads the collections:
<ion-list ng-controller="NavigationCtrl" ng-repeat="collection in study.collections">
<ion-item nav-clear menu-close ng-click="go('app.studies')" class="item item-icon-left brand-base-text-color">
<i class="icon ion-ios-paper"></i>
{{collection.name}}
</ion-item>
How can I fix this?