henry
henry

Reputation: 37

Starting an Angular Application

This is my first post and I am really new to computer programming so I apologize ahead of my time if my question is super simplistic. So I am trying to start an angular application and I currently have this:

<!DOCTYPE html>
<html>
 <head ng-app>
<title>Hello World</title>

<body>

</head>

<h1>{{2+2}}</h1>

</body>
<script type="<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js">    </script>
</head>

What is supposed to happen is that when I click the html page there should be the number 4 pop up but instead this pops up: {{2+2}}. I am assuming that my angular code is not correctly linked but I am not sure. Do you have any ideas?

Upvotes: 2

Views: 76

Answers (2)

Miyuru Ratnayake
Miyuru Ratnayake

Reputation: 456

Please find below the corrected html:

<!DOCTYPE html>
<html>
 <head>
  <title>Hello World</title>
 </head>
<body ng-app>

<h1>{{2+2}}</h1>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script>
</body>
</html>

Place the <body> tag in correct place. Moved the ng-app to body tag. Place the corrected script tag within <body>

Working sample: http://plnkr.co/edit/T15fetn913Fwn2uJ5pcj?p=preview

Upvotes: 2

Keith James
Keith James

Reputation: 167

Explanation: The body of an html page is where the components that display on a page will be declared.

- Overlying declaration of html -where you put meta data, scrip imports, css imports, and title. Basically things the page will use - all other tags from anchors to spans, things the user sees Note*** nothing can go in between these tags

Visit w3schools for a great tutorial on this... http://www.w3schools.com/html/default.asp

Upvotes: 0

Related Questions