javascript - Angular in 60ish minutes - What's wrong with this code? -


i have started learn angular , following angular in 60 minutes first step. on page-48, there example code shown below, simple controller display contents of customers property in page.

<!doctype html>  <html ng-app="">  <head>  	<title></title>  </head>  <body>  	  	<div class="container" ng-controller="simplecontroller">  		<h3>adding simple controller</h3>  		<ul>  			<li ng-repeat="cust in customers">  				{{cust.name}} - {{cust.city}}  			</li>  		</ul>  	</div>    	<script>  		function simplecontroller($scope) {  			$scope.customers = [  				{name: 'john doe', city: 'new york'},  				{name: 'jane doe', city: 'miami'},  				{name: 'moan doe', city: 'montreal'}  			];  		}  	</script>  	<script src="/usr/local/angular-1.3.16/angular.js"></script>  </body>  </html>

the expected output is:

adding simple controller

  • john doe - new york
  • jane doe - miami
  • moan doe - montreal

but can't see bulleted items. have been plucking hairs quite time. thought ask community before go bald. can tell me what's wrong code?

using version 1.3.16, cannot longer declare global controller function. instead, define module , controller:

angular.module('app', []).controller('simplecontroller', function ($scope) {             $scope.customers = [                 {name: 'john doe', city: 'new york'},                 {name: 'jane doe', city: 'miami'},                 {name: 'moan doe', city: 'montreal'}             ];         }); 

in html, add ng-app correct module name:

<body ng-app="app"> 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -