【发布时间】:2015-03-19 04:34:40
【问题描述】:
我的项目是关于创建帖子的。成功创建帖子后,页面将被重定向到帖子显示页面。在帖子显示页面中,给出了帖子索引的链接。我正在使用 ui-sref 指令进行重定向。
我面临的问题 - 重定向回索引页面后,新帖子未显示。该页面被缓存并显示旧结果。我需要重新加载页面并获取所有结果
我在 $http 中添加了 cache : false 选项但没有成功
代码
路线
.state('main.tabs.dash', { 网址:'/破折号', 意见:{ '制表符':{ templateUrl: 'views/tab-dash.html', 控制器:'PostsCtrl' } } })查看
<a ui-sref="main.tabs.dash">back to Index</a>
控制器
'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);
});
}]);
【问题讨论】:
-
我可以直接建议的一件事是,您可以查看 ui-router 的
resolve获取状态数据的功能。 -
您能在开发工具的网络选项卡上看到正在排队的请求吗?
-
no in network tab request is not queued.. 它正在加载缓存的结果
标签: angularjs angular-ui-router