MoSheikh MoSheikh - 5 months ago 16
AngularJS Question

Initializing Angular "Hello World' App

really basic question: a "hello world" app to start out practicing Angular works until I try to add the controller, at which point the expression doesn't work on the page.

<!doctype html>
<html ng-app='app'>
<head>
<link rel='stylesheet' href='css/styles.css'>
<link rel='stylesheet' href='css/bootstrap.min.css'>
<script src='js/app.js'></script>
<script src='js/angular.min.js'></script>
</head>
<body>
<div class='container col-md-6 col-md-offset-6 panel' ng-controller='FormController'>
<input type='text' ng-model='name' placeholder='Enter your name'>
<h1>Hello {{name}}</h1>
</div>

</body>
</html>


JS:

angular.module('app', []).controller('FormController', function($scope){
$scope.name = 'Test';
});


The page just ends up displaying {{name}} but if I take out the controller and the 'app' module, it works just fine. Help would be great, thank you.

SSH SSH
Answer

You should change order of including js files.

<script src='js/angular.min.js'></script>
<script src='js/app.js'></script>