My project is about posts creation. On successfull creation of post, page will be redirected to post show page. In the post show page a link to posts index is given. I'm using ui-sref directive for redirection.
Issue I'm facing- after redirecting back to index page the new posts are not showing up. the page is cached and showing old results. I need page to be reloaded and fetch all results
i have added cache : false option in $http but no success
code
routes
.state('main.tabs.dash', {
url: '/dash',
views: {
'tab-dash': {
templateUrl: 'views/tab-dash.html',
controller: 'PostsCtrl'
}
}
})
view
<a ui-sref="main.tabs.dash">back to Index</a>
controller
'use strict';
myApp.controller('PostsCtrl', ['$scope', '$http', '$location', 'Auth', '$state', '$rootScope', 'registrationData', function ($scope, $http, $location, Auth, $state, $rootScope, registrationData) {
$scope.posts = {};
$http({
url: $rootScope.url + '/posts',
method: 'GET',
cache: false,
params: {
user_email: xxxx,
user_token: xxxx
},
headers: {
'Authorization': 'Token token=' + xxxx,
'Accept': 'application/json'
}
}).success(function (data) {
$scope.posts = data;
}).error(function (error) {
console.log(error);
});
}]);
resolvefunctionality for fetching data for a state.