MCQ

AngularJs MCQs – Multiple Choice Questions and Answers – Part 2

Multiple choice questions and answers (MCQs) on AngularJs to prepare for exams, tests, and certifications. These questions are taken from a real written exam and some parts are taken from an interview. So you will find questions on basic techniques such as curd operations, HTTP services, template, routing, and more. This quiz will easily prepare anyone to pass their online test.
 

1. Which directive initializes an AngularJS application?

A ng-init

B ng-app

C ngSrc

D ng-start

B
Definition 1: The ng-app directive is used to initialize an AngularJS application. When this directive is in place in an HTML page, it tells Angular that this HTML page is an AngularJS application.

Example:

<div ng-app="">

	My favorite languages : {{ "JavaScript" + "Java" }}

</div>

Definition 2: The ng-app directive tells AngularJS that this is the root element of the AngularJS application. All AngularJS applications must have a root element. You can only have one ng-app directive in your HTML document. If multiple ng-app directives appear, the first one will be used.

 

 

2. Which of the following is not a valid Filter in AngularJs?

A lowercase

B orderby

C email

D currency

C
email is not a valid Filter in AngularJs

 

 

3. What is the responsibility of the controller in AngularJs?

A Controling data.

B Displaying data.

A
The controller controls the data. The view is responsible for displaying data.

 

[st_adsense]  

4. AngularJS directives are used in ________

A Model

B View

C Controller

D Module

B
Directives are attributes on a DOM element that tell AngularJS to attach a specified behavior to a DOM element or even transform the DOM element and its child elements. In short, it extends HTML. Most directives in AngularJS start with ng- where ng stands for Angular.

 

 

5. Which Angular directive is used to bind the value of HTML controls (input, select, textarea) to application data?

A ng-bind

B ng-cloak

C ng-model

D ng-blur

C
With ng-model directive, you can bind the value of an input to a variable created in AngularJS. Example:

<div ng-app="myApp" ng-controller="myCtrl">
  Name: <input ng-model="name">
</div>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
  $scope.name = "Alex Babtise";
});
</script>

 

 

6. Which directive binds app data to HTML tags in AngularJS?

A ng-app

B ng-model

C ng-bind

D All the answers are true

C
The ng-bind directive tells AngularJS to replace the content of an HTML element with the value of a given variable or expression.

If the value of the given variable or expression changes, the content of the specified HTML element will also be changed.

The following example associate the innerHTML of the element <p> to myStr variable:

<div ng-app="" ng-init="myStr='Welcome to WayToLearnX'">
	<p ng-bind="myStr"></p>
</div>

 

 

7. Which of the following is a filter in Angular Js?

A Currency

B Date

C Uppercase

D All the answers are true

D
AngularJS provides filters to transform data:

  • currency : Formats a number in a currency format.
  • date: Format a date in a specified format.
  • filter : Select a subset of elements in an array.
  • json : Format an object to a JSON string.
  • limitTo : Limit an array/string, to a specified number of elements/characters.
  • lowercase : Format a string in lowercase.
  • number : Formats a number into a string.
  • orderBy : Sorts an array.
  • uppercase : Format a string in uppercase.

 

[st_adsense]  

8. How to combine filter and expression?

A Using the comma {{ expression, filtre }}

B Using point {{ expression. filtre }}

C Using Pipe {{ expression | filtre }}

D Using Slash {{ expression / filtre }}

C
Using Pipe {{ expression | filtre }}

 

 

9. What is data-binding in AngularJS?

A Synchronization between Model and View

B Synchronization between Controller and View

C Synchronization between Model and Controller

D None of the above

A
Data-binding in AngularJS applications is the automatic synchronization of data between the Model and Vue components. The way AngularJS implements data-binding allows you to treat the Model as the single source of truth in your application. The view is a projection of the Model at all times.

 

 

10. What directive is used to specify a controller in an HTML element?

A Controller

B ng-control

C ng-controller

D ng-ctrl

C
ng-controller is used to specify a controller in an HTML element.

 

mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More [st_adsense]

Leave a Reply

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