AngularJS喷油器错误未捕获错误:[$Injector:modulerr]
我是AngularJS的新手,我正在尝试遵循一些可伸缩应用程序的结构,并尝试让Firebase工作。但是,我在喷油器上遇到了一个简单的错误。当我查看错误树时,它似乎是所有AngularJS引用,我在代码中没有看到对对象的引用。我想我找错地方了AngularJS喷油器错误未捕获错误:[$Injector:modulerr],angularjs,dependency-injection,Angularjs,Dependency Injection,我是AngularJS的新手,我正在尝试遵循一些可伸缩应用程序的结构,并尝试让Firebase工作。但是,我在喷油器上遇到了一个简单的错误。当我查看错误树时,它似乎是所有AngularJS引用,我在代码中没有看到对对象的引用。我想我找错地方了 Failed to instantiate module MyApp due to: Error: [$injector:unpr] http://errors.angularjs.org/1.3.11/$injector/unpr?p0=e at
Failed to instantiate module MyApp due to:
Error: [$injector:unpr] http://errors.angularjs.org/1.3.11/$injector/unpr?p0=e
at Error (native)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:6:417
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:38:307
at d (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:36:308)
at Object.e [as invoke] (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:37:64)
at d (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:35:301)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:35:425
at s (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:7:302)
at g (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:35:202)
at Ob (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:38:435
您似乎没有正确理解
$scope
对于routeProvider
,它是templateUrl
,而不是templateUrl
。对于TeamCtrl
,如果要将对象绑定到视图,请记住将此对象添加到$scope
angular.module('MyApp').config(function($routeProvider) {
$routeProvider
.when('/', {
controller: 'TeamCtrl',
templateUrl: 'team.html'
})
.otherwise({
redirectTo: '/'
});
});
angular.module('MyApp').controller('TeamCtrl', ['$scope', '$firebase', 'Teams',
function ($scope, $firebase, Teams) {
$scope.Teams = Teams;
$scope.team = {};
$scope.SaveTeam = function(team) {
$scope.Teams.$add({
Id: $scope.team.id,
Name: $scope.team.Name,
Wins: $scope.team.Wins,
Losses: $scope.team.Losses
});
};
$scope.team.id = "";
$scope.team.Name = "";
$scope.team.Wins = "";
$scope.team.Losses = "";
}
]);
对于team.html
<div ng-repeat="team in Teams">
<h2>{{team.Name}}</h2>
{{team.Wins}} / {{team.Losses}}
</div>
{{team.Name}
{{team.Wins}/{{team.loss}
您的示例中似乎有输入错误,templateUrl
而不是templateUrl
。此外,我没有看到任何喷油器错误,一切正常。当我的angular.module('appname',['somemodule'])
仍在调用somemodule
时,我出现了此错误。我删除了与该模块相关的文件,但忘记删除该模块名称。感谢更新。我把所有的东西都放在一个文件中,而不是我所拥有的那些零碎的文件,因此使用了“angular.module('MyApp'),而不是使用“var app=”,这可能意味着我的依赖关系是基于包含的。我必须检查组合JavaScript。我想我需要再次检查我这边的代码。主要是想看看如何克服AngularJS错误。