AngularJS错误:未知提供商
AngularJS Error: Unknown provider
我得到了经典的经典错误:未知的提供者:UserModelProvider <- UserModel与angular JS。我的代码是这样的:
var ClabborApp = angular.module('clabbor', []);
ClabborApp.factory('UserModel', function() {
var UserModel = {};
var list = [];
UserModel.getItem = function(index) {
return list[index];
}
UserModel.addItem = function(item) {
list.push(item);
}
UserModel.removeItem = function(item) {
list.splice(list.indexOf(item), 1)
}
UserModel.size = function() {
return list.length;
}
return UserModel;
});
function FollowersCtrl($scope, UserModel) {
$scope.followers = [{
text : 'learn angular',
done : true,
'name' : 'James'
}, {
text : 'build an angular app',
done : false,
'name' : 'John'
}];
}
我的html是这样的:
<html lang="en" ng-app>
<meta charset="utf-8">
<body ng-app="clabbor">
<div class="content follow" ng-controller="FollowersCtrl">
<ul class="clearfix">
<!-- Show max 12 followers -->
<li ng-repeat="follower in followers">
{{follower.name}}
</li>
</ul>
</div>
</body>
</html>
我以为我是按书做的,但我得到了错误。有人知道会是什么吗?
从html
标签中删除ng-app
属性。这是正在工作的Jsfiddle: http://jsfiddle.net/eA2xx/。不能有多个ng-app
相关文章:
- 角度模态服务未知提供商
- JsFiddle:未知提供商:$intervalProvider <- $interval
- 工厂和控制器,未知提供商
- 未知提供商:$resourceProvider - AngularJS
- 未知提供商:捆绑后$resourceProvider
- AngularJS + RequireJS.未知提供商:$routeProvider
- 未知提供商AngularJs在添加“时”;.运行”;
- Angular未知提供商错误
- 未知的自定义过滤器提供商Ionic/AngularJS
- 在AngularJS中,当自定义服务注入到不同的模块时,未知的提供商
- AngularJS错误:未知提供商
- 为什么我得到$injector:unpr(未知提供商)在这个单页应用程序
- 在angularJS中使用angular-cached-resource的未知提供商
- Angularjs、Typescript、Uglify和static $inject:未知提供商
- Angular $injector——为Angular提供的未知提供商's $timeout
- 未知的提供商:ngStorageProvider <-在尝试使用Angular的ngStorage时使用ngStorag
- 未知提供商:uniqueFilterProvider,在Angular.js中使用唯一过滤器
- 将输入字段值传入angularjs $resource undefined,错误显示未知的作用域提供商
- Angularjs、Typescript、Uglify实例化myApp模块失败未知提供商:a
- 错误:[$injector:unpr]未知提供商:ngCsv <- ngCsv <- dynamicDemoContro