Angular指令抛出错误:[$ injector:unpr] [英] Angular directive throws Error: [$injector:unpr]
本文介绍了Angular指令抛出错误:[$ injector:unpr]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理一个项目,需要修改一些代码来解决错误
指令:
<$ p $($)$ $ $ $ $'$'$ $ $ $ $ $ $ $ $ $ $'$'$'$'$'$' ){
return {
// code
};
});
})();
只会在缩小版本中引发错误。
我使用的角度1.5.9
我想我需要定义$过滤器的地方。
解决方案
我假设你有应用程序已经定义的地方。
你似乎没有注入$ filter,试试这个: (){
'use strict';
angular.module(' myApp')。directive(myDirective,[$ filter,function($ filter){
return {
// code
};
}]);
})();
I am working on an project and need to modify some code to resolve an error
directive:
(function () {
'use strict';
angular.module('myApp').directive("myDirective", function ($filter) {
return {
// code
};
});
})();
This throws an error with the minified version only. I am using angular 1.5.9
I think I need to define $filter somewhere.
解决方案
I assume you have the app already defined somewhere.
You seem to have not injected $filter, try this instead:
(function () {
'use strict';
angular.module('myApp').directive("myDirective", ["$filter", function ($filter) {
return {
// code
};
}]);
})();
这篇关于Angular指令抛出错误:[$ injector:unpr]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文