user3618922
user3618922

Reputation: 181

Angular JS and ng-model not displaying

I am a newbie at Angular JS and this is what I started with:

var myApp = angular.module('myApp', []);

myApp.controller('WizardController', ['$scope', function($scope){

  $scope.user = {};
  $scope.displayName = 'Hello';

}]);

user is used to gather the data in the input fields in my steps <input type='text' ng-model='user.name'> and when I call it like so {{user.name}} what is inside the input text appears in a next step.

My question is how do I get $scope.displayName to display on my page.

<p ng-model="displayName"></p>
<p>{{displayName}}</p>
<p><input type='text' ng-model='displayName'></p>

I have tried all of these and none seem to work. Please help.

here is a jfiddle http://jsfiddle.net/Fc7KZ/

Upvotes: 0

Views: 1094

Answers (2)

Dalorzo
Dalorzo

Reputation: 20024

Make sure you added the ng-app and ng-controller attributes to your html

<body ng-app="myApp" ng-controller="WizardController">
<p ng-model="displayName"></p>
<p>{{displayName}}</p>
<p><input type='text' ng-model='displayName'></p>
</body>

Update 1:

Your js fiddle did not have angular library here is the version corrected:

http://jsfiddle.net/Fc7KZ/2/

Upvotes: 2

Terry
Terry

Reputation: 14219

You seem to be using angular-wizard. Your Fiddle doesn't include Angular or Lodash, which are both pre-requisites of that project. I'm guess your local code doesn't either, if not then that's your problem.

Upvotes: 0

Related Questions