0

Im getting started with Angular.js. I am trying the data binding that angular offers

With this code I expect that whatever I type in the dialogue box is rendered underneath in the browser. WHy isn't that happening here? What am I missing?

 <!Doctype html>
 <html ng-app>
 <head>
<title>Simple App</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js">   </script>
 </head>
 <body>
<input ng-model="name" type="text" placeholder="Your name">
<h1>Hello {{name}}</h1>

 </body>
 </html>

This is what Im seeing:

enter image description here

9
  • Is the page running on a server? Any errors in the console? Commented Apr 15, 2014 at 15:35
  • Sorry if this is stupid but. Ive installed node and npm. How do I run a server? Commented Apr 15, 2014 at 15:36
  • I mean Wamp server or like that Commented Apr 15, 2014 at 15:36
  • 1
    Any errors in the browser console Commented Apr 15, 2014 at 15:39
  • 1
    Did adding ng-app fix your problem? If it does you should state so clearly, because editing your answer to include it might create confusion, when it was the most obvious omission in your question originally. Commented Apr 15, 2014 at 15:40

3 Answers 3

1
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js">   </script>

should be

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js">   </script>
Sign up to request clarification or add additional context in comments.

Comments

0

Try to add ng-app in the html

<!Doctype html>
<html>
 <head>
<title>Simple App</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js">   </script>
 </head>
 <body ng-app="myapp">
<input ng-model="name" type="text" placeholder="Your name">
<h1>Hello {{name}}</h1>

 </body>
 </html>

5 Comments

Added ng-app and it didnt do anything
How do you run this page?
im just refreshing the browser
No Im not using a wamp server. Im on a mac and I have installed node.js. How can I run server? Is there any tutorial for this?
There is no need for a server btw
0

<!DOCTYPE html>
<html ng-app>

  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
  </head>

  <body>
    <input ng-model="name" type="text" placeholder="Your name">
    <h1>Hello {{name}}</h1>
  </body>

</html>

Working example

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.