I was trying to run a simple Angular example using a controller. However, it doesn't seem to work.
Here is the HTML:
<!DOCTYPE html>
<html ng-app = "app">
<head>
<title></title>
<script type="text/javascript" src="js/lib/angular.min.js"></script>
<script type="text/javascript" src="js/my.js"/>
</head>
<body>
<label for = "fname">Name:</label><input type="text" id="fname" ng-model="name"/>{{name}}
<div class="container" ng-controller="SimpleController">
<ul>
<li ng-repeat="hero in heroes">{{hero.name}} - {{hero.city}}</li>
</ul>
</div>
</body>
</html>
The Script my.js is :
angular.module("app",[]).controller('SimpleController',[function ($scope){
$scope.heroes =
[
{name:"Bruce Wayne", city:"Gotham"},
{name:"Kal-El", city:"Metropolis"},
{name:"Barry Allen", city:"Central City"},
{name:"Kara Jor-El", city:"National City"},
{name:"Shazam", cuty:"Fawcett City"}
];
}]);
On my local system, the ng-model directive works. But the controller doesn't. I'm using 1.4.x (stable) Angular js.
I tried other question posted and did what the answers suggest, still no result. So what am I doing wrong here?
Created a fiddle as well. Though in the fiddle, even ng-model isn't working.
ng-app="app"attribute to your opening<body>tag