gpt4 book ai didi

javascript - Angular.js-providerInjector 错误

转载 作者:行者123 更新时间:2023-11-28 20:31:40 26 4
gpt4 key购买 nike

我在 Angular 提供程序方面遇到问题,收到此错误:

Row 2696: Error: Unknown provider: a

使用未缩小的 Angular v 1.06,第 2696 行:

providerInjector = createInternalInjector(providerCache, function() {
throw Error("Unknown provider: " + path.join(' <- '));
}),

这是代码:

var myApp = angular.module('myApp', [], function ($interpolateProvider) {
$interpolateProvider.startSymbol('{[{');
$interpolateProvider.endSymbol('}]}');
});

myApp.directive('buttonsRadio', function() {
[...]
});


myApp.controller('MainController', function MainController ($scope) {
[...]
})

有什么想法吗?

编辑:添加错误消息:

Error: Unknown provider: aProvider <- a
createInjector/providerInjector<@/libs/angular.js:2696
getService@/libs/angular.js:2824
createInjector/instanceCache.$injector<@/libs/angular.js:2701
getService@/libs/angular.js:2824
invoke@/libs/angular.js:2842
instantiate@/libs/angular.js:2874
@/libs/angular.js:4759
applyDirectivesToNode/nodeLinkFn/<@/libs/angular.js:4338
forEach@/libs/angular.js:138
nodeLinkFn@/libs/angular.js:4323
compositeLinkFn@/libs/angular.js:3969
compositeLinkFn@/libs/angular.js:3972
nodeLinkFn@/libs/angular.js:4354
compositeLinkFn@/libs/angular.js:3969
publicLinkFn@/libs/angular.js:3874
bootstrap/resumeBootstrapInternal/</<@/libs/angular.js:963
Scope.prototype.$eval@/libs/angular.js:8011
Scope.prototype.$apply@/libs/angular.js:8091
bootstrap/resumeBootstrapInternal/<@/libs/angular.js:961
invoke@/libs/angular.js:2857
bootstrap/resumeBootstrapInternal@/libs/angular.js:960
bootstrap@/libs/angular.js:973
angularInit@/libs/angular.js:934
@/libs/angular.js:14756
f.Callbacks/n@http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:2
f.Callbacks/o.fireWith@http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:2
.ready@http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:2
B@http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js:2

/libs/angular.js
Line 5704

最佳答案

在运行 uglify 或任何其他 ofuscator/压缩算法之前,您应该运行 grunt 任务 ng-annotate ,它将依赖项添加为字符串作为可注入(inject)数组,这使您的代码更加清晰,因为可注入(inject)注释可以作为构建步骤自动添加,而不必手动编码。

myApp.controller('MainController', function MainController ($scope) {
[...]
})

变成:

myApp.controller('MainController', ['$scope', function MainController ($scope) {
[...]
}])

看看:https://github.com/olov/ng-annotate

更新: ng-min AngularJS Pre-minifier 已弃用 –> 使用 ng-annotate

关于javascript - Angular.js-providerInjector 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16242406/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com