Having problem with my angular app, when I refresh page it doesn't show me correct page. It looks like the way I pass parameter to the page is not right.
So I have my state in the ui-router:
.state('stateDashboard', {
url: '/dashboard',
templateUrl: '/templates/dashboard.html',
controller: 'dashboardController'
})
In the page where I have list of Dashboards:
<div class="tile" ng-repeat="d in dashList" ng-class="[d.tileColour, d.tileSize]" ui-sref="stateDashboard" ng-click="setDashboard(d.id)">
<div class="tile-body">
<i class="fa fa-dashboard"></i>
</div>
<div class="tile-object">
<div class="name">
{{d.name}}
</div>
</div>
</div>
where setDashboard(id) sett id to $rootScope.dashId
and in my controller to display dashboard I have:
Dashboards.getDashboard({ id: $rootScope.dashId }).$promise.then(function (result) {
$rootScope.model = result;
}
So now when I refresh the page $rootScope.dashId is undefined so doesn't display page correctly. How can I fix it?
dashList, which would be$scope.dashList. the JavaScript you posted is referring to$rootScope.model. Not only are you not showing how you get from$rootScopeto$scope, but using$rootScopeat all is an anti-pattern.