第一个$ http.post承诺(当与.then一起使用时)返回一个对象没有问题,但是当我嵌套另一个$ http.post承诺时(也可以使用。然后)我永远不会得到一个对象返回。无论我做什么,它总会回报一个承诺。
function getDocumentPages($http) {
var data = { fileName: '@fileNameUrlSafe' };
return $http.post(controllerBaseUrl + "GetDocumentPages", data)
.then(function successCallback(response) {
// =======================================
// THE LINE BELOW ALWAYS RETURNS A PROMISE
// =======================================
var fieldPages = getDocumentFormFields($http);
var tempModel = {
pages: response.data,
fieldPages: fieldPages
};
return tempModel;
}, function errorCallback(response) {
console.log(response);
});
}
function getDocumentFormFields($http) {
var data = { fileName: '@fileNameUrlSafe' }
return $http.post(controllerBaseUrl + "GetDocumentFormFields", data)
.then(function successCallback(response) {
return response.data;
}, function errorCallback(response) {
console.log(response);
});
}
在控制台中的任何错误? –
没有没有错误 – RichC