我是AngularJS中的新成员 我编写了一个有错误的应用程序,不会显示整个代码。那些有角码的代码部分没有出现。错误:ng:areq在AngularJS中未定义的错误参数和参数
MAIN.js文件
var app = angular.module('app', [
'ngRoute',
'artistController'
]);
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider.
when('/list' , {
templateUrl: 'list/list.html',
controller: 'artistController'
}).otherwise({
redirectTo: '/list'
});
}]);
var artistController = angular.module('artistController' , []);
artistController.controller("ListController", [
"$scope", "$http" ,function ($scope , $http) {
$http.get('file:///C:/wamp/www/angular - copy/data.json').success(function (data) {
$scope.artists = data;
});
}
]);
的index.html
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="utf-8">
<title>angular</title>
<link rel="stylesheet" href="file:///C:/wamp/www/angular/bootstrap-3.3.7- dist/css/bootstrap.min.css" media="screen" title="no title">
<link rel="stylesheet" href="file:///C:/wamp/www/angular - copy/main.css" media="screen" title="no title">
<script src="file:///C:/wamp/www/angular/angular-1.5.8/angular.min.js" charset="utf-8"></script>
<script src="file:///C:/wamp/www/angular/angular-1.5.8/angular-route.min.js" charset="utf-8"></script>
<script src="file:///C:/wamp/www/angular - copy/main.js" charset="utf-8"> </script>
</head>
<body>
<div class="containor" ng-view></div>
</body>
</html>
list.html
<div>
<h2>Search directory</h2>
<label>Search:</label>
<input placeholder="Search for your person" autofocus="" ng-model="query"> </input>
<label>By:
<select ng-model="artistOrder">
<option value="lastName">lastName</option>
<option value="firstName">firstName</option>
</select>
</label>
</div>
<ul class="background" ng-controller="ListController">
<li class="center" ng-repeat="x in artists | filter:query | orderBy:artistOrder">
<img src="img.png" alt="photo" />
<h1 class="col-lg-4">{{ x.firstName | uppercase }}</h1>
<h2 class="col-lg-5">{{ x.lastName }}</h2>
</li>
</ul>
</section>
在铬我得到了一个错误Argument 'artistController' is not aNaNunction, got undefined
任何想法? 感谢看待
看起来你应该把你的artistController挂在你的app模块之外。你只是自己公开宣布它,所以它不会在你的ng-app模块(即“app”)中找到。 –