我试图找一个问题超过一个小时。我收到了一个错误:
Error: Argument 'SimpleController' is not a function, got undefined
有谁知道为什么SimpleController未定义?谢谢!
<!DOCTYPE html>
<html ng-app>
<body>
<div ng-controller="SimpleController">
<ul>
<li ng-repeat="customer in customers">
{{ customer.name }}
</li>
</ul>
</div>
<script type="text/javascript"
src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script>
function SimpleController($scope) {
$scope.customers = [
{ name: 'Dave Jones', city: 'Kentucky' },
{ name: 'Mister X', :city: 'SF' }
];
}
</script>
</body>
</html>
答案 0 :(得分:5)
您的阵列中有拼写错误。删除这个冒号,它将起作用
$scope.customers = [
{ name: 'Dave Jones', city: 'Kentucky' },
{ name: 'Mister X', **:** city: 'SF' }
];
答案 1 :(得分:2)
删除:
前面的:city:
。