Friday, August 1, 2014

Lesson 3 : Basic Example - Angular JS

Refer the below HTML, there is a keyword ng-app.

What is ng-app?
  * ng-app is a directive that informs to Angular that <HTML> or<div> tag is the root(or owner) of this    
     entire document.
  * if you want to enable Angular only at specific location in your webpage then you can define ng-app
     attribute to any DIV or other tag.
      **example <div ng-app"=""></div>, here Angular will applicable for only particula div tag not for entire
     document.

Why is ng?
 * ng stands Angular.
 * Whenever if you seen any attribites starts with ng, that means they have used Angular.

Syntax
<body ng-app = "bodyApp"></body>
<html ng-app = "htmlApp"></html>
<div ng-app = "divApp"></div>

you can include ng-app with any tags,if you are not include angular will not work.
Angular will start automatically once page loads, but sometimes we have to load the particilar div using angular by manually, there we have to use JS like
angular.bootstrap();

Note : Whenever page loads, angular Js loads automatically.

HTML Strucure

<html ng-app="">
<body>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>

</body>
</html>

2 comments:

  1. Hi Mahesh,
    Thanks, Now i have a clear idea in
    How Angularjs initially works?

    ReplyDelete
  2. Thanks Thamizh, if you have more information, share with us. Any question, please let me know i will learn from it as well.

    ReplyDelete