Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic/AngularJS$资源超时配置设置不起作用_Angularjs_Get_Ionic Framework_Resources_Timeout - Fatal编程技术网

Ionic/AngularJS$资源超时配置设置不起作用

Ionic/AngularJS$资源超时配置设置不起作用,angularjs,get,ionic-framework,resources,timeout,Angularjs,Get,Ionic Framework,Resources,Timeout,我一直在尝试为$resource设置超时值(以毫秒为单位),以便如果服务器在10*1000毫秒内没有响应,我希望工厂中的服务返回错误承诺 我的工厂采用以下方法: service.getDelta = $resource(BASE_API_URL + '/delta/:inTable/:inDate', {inTable: '@inTable', inDate: '@inDate'}, {query: {timeout: 10*1000}}); 在控制器中,我执行以下操作: getDataPr

我一直在尝试为$resource设置超时值(以毫秒为单位),以便如果服务器在10*1000毫秒内没有响应,我希望工厂中的服务返回错误承诺

我的工厂采用以下方法:

service.getDelta = $resource(BASE_API_URL + '/delta/:inTable/:inDate', 
{inTable: '@inTable', inDate: '@inDate'},
{query: {timeout: 10*1000}});
在控制器中,我执行以下操作:

getDataPromises.push(remoteService.getDelta.query({inTable: "table1", inDate: clientDateLastModified}).$promise);
getDataPromises.push(remoteService.getDelta.query({inTable: "table2", inDate: clientDateLastModified}).$promise);
getDataPromises.push(remoteService.getDelta.query({inTable: "table3", inDate: clientDateLastModified}).$promise);
getDataPromises.push(remoteService.getDelta.query({inTable: "table4", inDate: clientDateLastModified}).$promise);
然后我检查以确保所有操作都成功,或者在其中一个失败时处理错误

$q.all(getDataPromises).then(
  function (result) {
    // NOTIFY SUCCESS
  },
  function (error) {
    // NOTIFY ERROR
  });
这一承诺的成功正如预期的那样实现了。如果我省略了timeout配置,我也会在promise中得到错误,比如404。但是,当我添加超时时,当我在错误回调中字符串化错误对象时,会得到以下结果:

{"line":13380,"column":32,"sourceURL":"file:///Users/ ... /www/lib/ionic/js/ionic.bundle.js"}
我是否误解了timeout属性的使用

我使用的是离子1.2.4,我相信是角度1.4.3

注意:我知道这个用例不能证明使用$resource是合理的,可以使用$http来完成,但我想体验一下使用它的感觉,因为我计划开发这个应用程序

谢谢