Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/444.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
Javascript 错误:[$http:badreq]http请求配置url必须是字符串。收到:{}_Javascript_Angularjs - Fatal编程技术网

Javascript 错误:[$http:badreq]http请求配置url必须是字符串。收到:{}

Javascript 错误:[$http:badreq]http请求配置url必须是字符串。收到:{},javascript,angularjs,Javascript,Angularjs,我把我的角度升级到1.5,我得到了这个错误。这是我的控制器中的代码 var reportURL=$rootScope.hostUrl+API\u VERSION+“/runreports/”+ encodeURIComponent(scope.reportName); reportURL+=“?输出类型=“+ encodeURIComponent(scope.formData.outputType)+ “&tenantIdentifier=“+$rootScope.tenantIdentifie

我把我的角度升级到1.5,我得到了这个错误。这是我的控制器中的代码

var reportURL=$rootScope.hostUrl+API\u VERSION+“/runreports/”+
encodeURIComponent(scope.reportName);
reportURL+=“?输出类型=“+
encodeURIComponent(scope.formData.outputType)+
“&tenantIdentifier=“+$rootScope.tenantIdentifier+
“&locale=“+scope.optlang.code+”&dateFormat=“+scope.df;
var inQueryParameters=buildReportParms();
如果(inQueryParameters>“”)报告URL+=“&”+inQueryParameters;
//允许ajax请求使用不受信任的URL。
reportURL=$sce.trustAsResourceUrl(reportURL);
get(reportURL,{responseType:'arraybuffer'})。
成功(函数(数据、状态、标题、配置){
var contentType=headers('Content-Type');
var file=newblob([data],{type:contentType});
var fileContent=URL.createObjectURL(文件);
//将表单数据作为数据url传递给iframe。
scope.baseURL=$sce.trustAsResourceUrl(fileContent);
});
从Angular 1.4.9开始,$http服务只接受纯字符串作为URL。如果传入具有toString()方法的对象,$http将引发异常


此代码的解决方法是什么?

不推荐使用
.success
方法。使用
config
对象的
params
属性对搜索参数进行编码。使用
responseType:'blob'
而不是将arraybuffer转换为blob。如果需要,请使用
.toString()
。不推荐使用
.success
方法。使用
config
对象的
params
属性对搜索参数进行编码。使用
responseType:'blob'
而不是将arraybuffer转换为blob。如果需要,请使用
.toString()