MoSheikh MoSheikh - 2 years ago 69
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'>
<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>
<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>



angular.module('app', []).controller('FormController', function($scope){
$ = '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.

Answer Source

You should change order of including js files.

<script src='js/angular.min.js'></script>
<script src='js/app.js'></script>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download