我剛纔給出了一個嘗試。我在CustomersController.js中定義了一個控制器。但是,當我運行時出現錯誤「錯誤:錯誤:areq錯誤論據」。我的CustomersController未找到。任何將不勝感激。謝謝。未找到控制器
這裏是我的HTML文件:
<!DOCTYPE html>
<html lang="en" data-ng-app>
<head>
<meta charset="UTF-8">
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,600,700,800,300' rel='stylesheet' type='text/css'>
</head>
<body ng-controller="CustomersController">
<h2>Customers</h2>
Filter: <input type="text" ng-model="customerFilter.name" />
<table>
<tr>
<th ng-click="doSort('name')">Name</th>
<th ng-click="doSort('city')">City</th>
<th ng-click="doSort('orderTotal')">Order Total</th>
<th ng-click="doSort('joined')">Joined</th>
</tr>
<tr ng-repeat="cust in customers | filter:customerFilter | orderBy:sortBy:reverse">
<td>{{ cust.name }}</td>
<td>{{ cust.city }}</td>
<td>{{ cust.orderTotal | currency }}</td>
<td>{{ cust.joined | date }}</td>
</tr>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js"></script>
<script src="app/controllers/customersController.js"></script>
</body>
</html>
,這裏是我的CustomerController.js
function CustomersController($scope){
$scope.sortBy = 'name';
$scope.reverse = false;
$scope.customers = [
{
joined: "2000-12-24",
name: "Charles",
city: "Fairfax",
orderTotal: "12414432.45"
},
{
joined: "2000-09-12",
name: "Jack",
city: "Altamonte Springs",
orderTotal: "5.9943"
},
{
joined: "2000-01-25",
name: "Bill",
city: "Waldorf",
orderTotal: "100"
}
],
$scope.doSort = function(propName){
$scope.sortBy = propName;
$scope.reverse = !$scope.reverse;
};
}
謝謝sss。我一直在尋找這個約2小時 – dowomenfart 2014-10-26 21:49:21
@ Donte'Trumble不客氣 – sylwester 2014-10-26 21:55:03