I'm following an example where I can make the first part example work, but then making a small change to restructure it by adding a application doesn't work (but should do the same thing) -- very basic example. Can you please help me understand
1) what's wrong with the code, and
2) how to debug this kind of thing
I'm including angular.min.js version 1.2.6
Example that works
<!DOCTYPE HTML>
<html ng-app="">
<head>
<title></title>
</head>
<body >
<div ng-controller="SimpleController">
<input type="text" ng-model="nameText" /> <span style="font-weight:bold"> {{ nameText }}</span>
<h3>Listing1</h3>
<ul>
<li ng-repeat="cust in customers | filter: nameText | orderBy: 'city' ">{{ cust.name | uppercase }} - {{ cust.city }} </li>
</ul>
</div>
<script>
function SimpleController($scope) {
$scope.customers = [
{ name: 'Dave Jones', city: 'Phoenix'},
{ name: 'Jamie Riley', city: 'Atlanta'},
{ name: 'Heedy Wahlin', city: 'Chandler'},
{ name: 'Thomas Winter', city: 'Seattle'}
];
}
</script>
<script src="libraries/angular.min.js"></script>
</body>
</html>
Similar Example that Doesn't Work
<!DOCTYPE HTML>
<html >
<head ng-app="demoApp">
<title></title>
</head>
<body>
<div ng-controller="SimpleController">
<input type="text" ng-model="nameText" /> <span style="font-weight:bold"> {{ nameText }}</span>
<h3>Listing1</h3>
<ul>
<li ng-repeat="cust in customers | filter: nameText | orderBy: 'city' ">{{ cust.name | uppercase }} - {{ cust.city }} </li>
</ul>
</div>
<script>
var demoApp = angular.module('demoApp', []);
function SimpleController($scope) {
$scope.customers = [
{ name: 'Dave Jones', city: 'Phoenix'},
{ name: 'Jamie Riley', city: 'Atlanta'},
{ name: 'Heedy Wahlin', city: 'Chandler'},
{ name: 'Thomas Winter', city: 'Seattle'}
];
}
demoApp.controller('SimpleController', SimpleController);
</script>
<script src="libraries/angular.min.js"></script>
</body>
</html>