Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.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
AngularJS错误[$injector:unpr]IE11中的未知提供程序_Angularjs_Internet Explorer 11 - Fatal编程技术网

AngularJS错误[$injector:unpr]IE11中的未知提供程序

AngularJS错误[$injector:unpr]IE11中的未知提供程序,angularjs,internet-explorer-11,Angularjs,Internet Explorer 11,我在谷歌或这里都找不到帮助。我是Angular的新手,我只在IE11及以下版本中遇到这个错误 我得到的错误是: 我的IE是葡萄牙语的因此第一个错误的翻译是:不可能获取未定义或null的“getAttribute”属性 这是我的app.config.js文件 //检查是否注册了可选模块。 //如果不是,请注册一个空的,以防止出错。 (功能(optDeps){ optDeps.forEach(功能(dep){ 试一试{ 角度模块(dep); }捕获(e){ 角模(dep,[]); } }) })

我在谷歌或这里都找不到帮助。我是Angular的新手,我只在IE11及以下版本中遇到这个错误

我得到的错误是:

我的IE是葡萄牙语的因此第一个错误的翻译是:不可能获取未定义或null的“getAttribute”属性

这是我的app.config.js文件

//检查是否注册了可选模块。
//如果不是,请注册一个空的,以防止出错。
(功能(optDeps){
optDeps.forEach(功能(dep){
试一试{
角度模块(dep);
}捕获(e){
角模(dep,[]);
}
})
})(['ui.carousel','ui.mask','vAccordion','ngAnimate']);
有棱角的
.模块('poletto'[
//第三方
“smoothScroll”,
“ui.carousel”,
“ui.mask”,
“vAccordion”,
“ngAnimate”,
//组成部分
“poletto.组件”,
//控制器
“poletto.控制器”,
//指令
“poletto.指令”,
//工厂
“poletto.工厂”,
//过滤器
'poletto.过滤器',
//服务
“poletto.服务”
])
.constant('CONSTANTS'{
BASE\u URL:document.currentScript.getAttribute('data-BASE-URL')
})
.config(函数($httpProvider){
$httpProvider.defaults.headers.common['X-Requested-With']='XMLHttpRequest';
})
.config(函数($locationProvider){
if(window.history.pushState){
$locationProvider.html5Mode({enabled:true,requireBase:false,rewriteLinks:false});
}
})
//使用按类名查找节点的函数扩展JQLite
.run(函数(){
angular.element.prototype.findBySelector=函数(选择器){
var匹配=[];
用于(输入此项){
//只推HtmleElement的
if(此[key].nodeType){
//节点列表到数组
var results=Array.prototype.slice.call(此[key].querySelectorAll(选择器));
匹配。推送。应用(匹配,结果);
}
}
返回角度元素(匹配);
};
})
不幸的是,它不能进行多填充,所以不能这样做。也许,您可以将基本url嵌入到其他地方,或者向脚本中添加一个
id
,并在老式javascript中检索它

<script id="main" data-base-url="https://my-api.com"></script>
常量
提供程序中,您可以执行以下操作:

var currentScript = document.getElementById('main');
.constant('CONSTANTS', {
    BASE_URL: document.getElementById('main').getAttribute('data-base-url')
})
不幸的是,它不能被多重填充,所以不能这样做。也许,您可以将基本url嵌入到其他地方,或者向脚本中添加一个
id
,并在老式javascript中检索它

<script id="main" data-base-url="https://my-api.com"></script>
常量
提供程序中,您可以执行以下操作:

var currentScript = document.getElementById('main');
.constant('CONSTANTS', {
    BASE_URL: document.getElementById('main').getAttribute('data-base-url')
})

这个问题源于使用
document.currentScript
,IE 11不支持它,而且显然不能进行多填充(至少很容易)。因此,您必须找到一种不同的方法来声明
BASE\uURL
常量

问题源于使用
document.currentScript
,IE 11不支持该脚本,而且显然无法进行多填充(至少很容易)。因此,您必须找到一种不同的方法来声明
BASE\uURL
常量

莱尼尔森的答案更令人满意,因此我建议你将其标记为被接受的答案。莱尼尔森的答案更令人满意,因此我建议你将其标记为被接受的答案。