AngularJs Interview Questions and Answers Part 1

1. What is the difference between ng-bind and ng-model in angularjs?
Ans. ng-bind binds the application data to html control
     ng-model binds the html control data to application data.

2. Which directive defines the start of Angularjs application?
Ans. The ng-app directive defines an AngularJS application.

3. What prefix is used for Angularjs attributes?
Ans. "ng" prefix. Example: ng-init,ng-model,ng-bind,..

4. Give any example for variable inititalization using Angularjs?
Ans. Generally, variable initialization is done using "ng-init" directive.
For example,

<div ng-app="" ng-init="Name='ABC'">

<p>Welcome <span ng-bind="Name"></span></p>


5. Print 2 table using Angularjs?

6. why expressions are used in Angularjs?
Ans. Generally, AngularJS binds data to HTML using Expressions.

7. How to dynamically change the color of an target "Div" element on input type value using Angularjs?
Ans. We can dynamically change the color of any element using angularjs, for example

<div ng-app="" ng-init="ColorName='Yellow'">

<input ng-model="ColorName" value="{{ColorName}}">

<div style="background-color:{{ColorName}}">I am Changed !!</div>


8. Give any example of define arrays and how to access them in Angularjs?
Ans. We can declare and initialize array elements in angularjs using "ng-init",

 <div ng-app="" ng-init="StudentMarksArray=[30,35,46,57,44,67]">

<p>The first element is <span ng-bind="StudentMarksArray[0]"></span></p>




Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker