Angularjs Interview Questions And Answers

angularjs interview questions and answers   Top 5 Angularjs Interview Questions And Answers

1) What is Angular JS?

It is a Javascript framework that has been developed by google and is open source. This can be added in the application using script tag.

<script src=""https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js""></script>
- Angular JS is client side framework.
- It handles the DOM elements in more structured way.


2) What are ng-directives in AngularJS?

It defines the Angular JS application.
ng-app - this directive defines the AngularJS application.
ng-model - It binds the value of HTML control.
ng-bind - it binds the application data to HTML view.

Example:

<div ng-app=""><br>
  <p>City: <input type="text" ng-model="city"></p><br>
  <p ng-bind="city"></p><br>
</div>


3) What is the use of ng-init directive in Angular JS?

It initializes the variables in Angular JS application.

Example:

<div ng-app="" ng-init=""city='NJ'><br>
<p>The city is <span ng-bind="city"></span></p><br>
</div><br>


4) What is angular JS expressions?

It is used to output the data in the application. These expressions are written in double curly braces. {{ expression }}
Example:

<p>The sum is: {{ 5 + 5 }}</p>


5) Using Angular JS, what will be the output of this code snippet?

<div ng-app="" ng-init=""q=20;d=80"><br>
<div ng-app="" ng-init=""city='NJ'"><br>
<p>Total dollar {{ q * d }} in city: <span ng-bind="city"></span></p><br>
</div>

The output is: Total dollar 1600 in city: NJ