I've been following a tutorial, the textbook assures me that this works, but it's bombing with
Error: [ng:areq] Argument 'SimpleController' is not a function, got
undefined
Why? I have linted it, been up and down it and I cannot see a problem. Why is SimpleController
coming up undefined?
<html ng-app>
<head>
<title>
</title>
</head>
<body>
<input type="text" ng-model="blah" />
<div ng-controller="SimpleController">
<h3>looping a data set</h3>
<ul>
<li ng-repeat="cust in customers | filter:blah | orderBy:'city'">
{{cust.name | uppercase}} - {{cust.city | lowercase}}
</li>
</ul>
</div>
<script src="angular.js"></script>
<script>
function SimpleController($scope)
{
$scope.customers = [
{name: 'John Smith', city: 'Phoenix'},
{name: 'Jane Smith', city: 'Pittsburgh'},
{name: 'John Doe', city: 'New York'},
{name: 'Jane Doe', city: 'Los Angeles'}
];
}
</script>
</body>
</html>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…