我想使用 gulp 将我的 src 文件注入到 html 中。我认为只要我首先包含模块文件,我就可以乱序执行此操作。
<script src="scripts/app.module.js"></script>
<script src="scripts/app.A.js"></script>
<script src="scripts/app.B.js"></script>
这是 plunkr 中的样子-
http://plnkr.co/edit/KkJcbSzz5rTb7pvkYySB?p=preview
angular.module('app', [])
.provider('A', function(B) {
this.$get = function() {};
})
.provider('B', function() {
this.$get = function() {};
});
但我明白了Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:unpr] Unknown provider: B
我理解这个错误,但我认为这是你可以做的。您可以通过服务来做到这一点-
http://plnkr.co/edit/vfsjWMGQJr89HL93WyxS?p=preview
angular.module('app', [])
.service('A', function(B) {
this.$get = function() {};
})
.service('B', function() {
this.$get = function() {};
});
难道不能用提供者来定义乱序的东西吗?