Hello World in Angularjs

Posted on Updated on

Before we get started with our first example, let’s discuss few basic directives we’ll be using in it.

  • ng-app: When a page is loaded in browser then it must be told that it is an AngularJS application. This directive is included in any of the parent tag.

    If this is not included the browser will load the page as normal HTML page and properties of AngularJS will not be rendered.
  • ng-model: To be able to store/bind the value of AngularJS application or values of HTML attribute one must use this directive.

    This will bind the value entered to “myValue”. There are some other ways by which value can be binded which we’ll see in later chapters.
  • {{expression}}: This will render the value stored in expression on page. We shall in below example how it is done.

 

Now let’s begin with our first example:

Hello World:

Output:

  • When run the program below page will load.
  • HelloWorld
  • Post adding any value:
  • HelloWorld-output

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.