我想在我收到数据并存储它之后使用函数,我怎么得不到我想要的结果以及我使用的代码。在http请求后调用
有人可以提供一些关于我在做什么错的细节吗?
我的代码:
$http({
method: 'GET',
url: 'JsonLocation'
}).then(
function successCallback(response) {
// this callback will be called asynchronously
// when the response is available.
self.responseData = response.data;
},
function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
console.log(response);
}
).then(
function completeCallback() {
// called when the http request is finished.
restyleData();
}
);
当加载页面时,一切都设在地方,我可以运行通过开发者选项restyleDate()
,那么它的工作原理。但是我只是想在加载完所有内容后才开启它,而不是手动完成。
删除第二个'.then'语句,并将你的'restyleData'方法放入你的'successCallback' –
那么它有什么特殊的问题呢?这个函数做什么? '我没有得到想要的结果'并不是非常明确 – charlietfl
@ChristopherMarshall这个函数似乎在所有数据都在页面之前被调用。我认为我的问题在于我在'restyle'之前处理来自角的ng-repeat。我需要在页面上显示所有数据后才能看到它。 – Marcel