【发布时间】:2015-09-06 22:52:31
【问题描述】:
这是应用的代码部分
<div class="container" data-ng-app="myApp" ng-controller="hController">
<li ng-repeat="x in names">
{{ x.Name + ', ' + x.Country }}
</li>
</ul>
控制器实现
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.get("http://localhost:8080/rest/hotel")
.success(function(response) {$scope.names = response.records;});
});
</script>
</head>
我可以在 Web 控制台中看到错误
错误:[ng:areq] http://errors.angularjs.org/1.3.14/ng/areq?p0=hotelController&p1=not%20a%20function%2C%20got%20undefined 在错误(本机) 在http://localhost:8080/resources/js/angular.min.js:6:417
我已经在路径中添加了 angular.min.js
【问题讨论】:
-
控制器的名字是customersCtrl,更改ng-controller