Home »
MCQs
AngularJS Multiple-Choice Questions (MCQs)
AngularJS is a JavaScript-based open-source front-end web framework for developing single-page applications. It is maintained mainly by Google and a community of individuals and corporations.
AngularJS MCQs: This section contains AngularJS Multiple-Choice Questions with Answers. These AngularJS MCQs are written for beginners as well as advanced, practice these MCQs to enhance and test the knowledge of AngularJS.
List of AngularJS MCQs
1. AngularJS is perfect for _______.
- Create Single Page Applications
- Creating a Desktop Application
- Create Web Services
- None of these
Answer: A) Create Single Page Applications
Explanation:
AngularJS is perfect for creating Single Page Applications (SPAs).
Discuss this Question
2. AngularJS is a _____.
- HTML Framework
- .Net Framework
- JavaScript framework
- Oracle Framework
Answer: C) JavaScript framework
Explanation:
AngularJS is a JavaScript framework.
Discuss this Question
3. AngularJS is distributed as a _______.
- JavaScript file
- PHP file
- XML file
- ASP file
Answer: A) JavaScript file
Explanation:
AngularJS is distributed as a JavaScript file.
Discuss this Question
4. Who developed AngularJS?
- Jesse James Garrett
- Douglas Crockford
- Miško Hevery
- Brendan Eich
Answer: C) Miško Hevery
Explanation:
AngularJS was developed by Miško Hevery.
Discuss this Question
5. Who maintained AngularJS?
- Google
- A community of individuals and corporations
- Oracle
- Both A. and B.
Answer: D) Both A. and B.
Explanation:
AngularJS is maintained by the Angular Team at Google and by a community of individuals and corporations.
Discuss this Question
6. Is AngularJS free for commercial use?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, AngularJS is free for commercial use.
Discuss this Question
7. AngularJS expressions are written inside _____.
- { expression }
- [{ expression }]
- _expression
- {{ expression }}
Answer: D) {{ expression }}
Explanation:
AngularJS expressions are written inside double braces: {{ expression }}.
Discuss this Question
8. Which directive can be used to write AngularJS expressions?
- ng-expression
- ng-bind
- ng-statement
- ng-bindexpression
Answer: B) ng-bind
Explanation:
The ng-bind can be used to write AngularJS expressions.
Discuss this Question
9. Which is the correct syntax to write an AngularJS expression using the ng-bind directive?
- ng-bind="expression"
- ng-bind={expression}
- ng-bind={"expression"}
- ng-bind="{{expression}}"
Answer: A) ng-bind="expression"
Explanation:
The correct syntax to write an AngularJS expression using the ng-bind directive is: ng-bind="expression"
Discuss this Question
10. An AngularJS module defines an ______.
- expression
- application
- element
- None of the above
Answer: B) application
Explanation:
An AngularJS module defines an application.
Discuss this Question
11. Which AngularJS function is used to create a module?
- module
- ng-bind
- angular.create
- angular.module
Answer: D) angular.module
Explanation:
AngularJS function angular.module is used to create a module.
Discuss this Question
12. Which is the correct syntax to create a module?
- var variable_name = angular.module("app_name", []);
- var variable_name = angular.module("app_name", []);
- var variable_name = angular.module("app_name", []);
- var variable_name = angular.module("app_name", []);
Answer: A) var variable_name = angular.module("app_name", []);
Explanation:
The correct syntax to create a module using the angular.module is:
var variable_name = angular.module("app_name", []);
Discuss this Question
13. In the below given statement, "myApp" parameter refers to ____.
- a JavaScript code in which the application will run
- a JSON file
- an HTML element in which the application will run
- SQL queries
Answer: C) an HTML element in which the application will run
Explanation:
In the given statement, myApp parameter refers to an HTML element in which the application will run.
Discuss this Question
14. Which prefix is used with the AngularJS directives?
- ag-
- ng-
- aj-
- All of the above
Answer: B) ng-
Explanation:
The ng- prefix is used with the AngularJS directives.
Discuss this Question
15. Which directive initializes an AngularJS application?
- ng-app
- ng-init
- ng-model
- ng-application
Answer: A) ng-app
Explanation:
The ng-app directive initializes an AngularJS application.
Discuss this Question
16. Which directive initializes application data?
- ng-app
- ng-init
- ng-model
- ng-application
Answer: B) ng-init
Explanation:
The ng-init directive initializes application data.
Discuss this Question
17. Which directive binds the value of HTML controls to application data?
- ng-app
- ng-init
- ng-model
- ng-application
Answer: C) ng-model
Explanation:
The ng-model directive binds the value of HTML controls to application data.
Discuss this Question
18. Which directive repeats an HTML element?
- ng-repeats
- ng-iterate
- ng-model
- ng-repeat
Answer: D) ng-repeat
Explanation:
The ng-repeat directive repeats an HTML element.
Discuss this Question
19. Which directive defines initial values for an AngularJS application?
- ng-app
- ng-init
- ng-model
- ng-repeat
Answer: B) ng-init
Explanation:
The ng-init directive defines initial values for an AngularJS application.
Discuss this Question
20. Write a statement with <div> element to initialize two variables (name and age)?
- <div ng-app="" ng-init="Name:'Alex';Age:21">
- <div ng-app="" ng-init="Name:'Alex',Age:21">
- <div ng-app="" ng-init="Name='Alex',Age=21">
- <div ng-app="" ng-init="Name='Alex';Age=21">
Answer: D) <div ng-app="" ng-init="Name='Alex';Age=21">
Explanation:
The correct statement to initiate the variables:
<div ng-app="" ng-init="Name='Alex';Age=21">
Discuss this Question
21. Consider the below statement, how to print the value of "StudentName"?
<div ng-app="" ng-init="firstName='John'">
<p>Input something in the input box:</p>
<p>Name: <input type="text" ng-model="StudentName"></p>
<p>You wrote: _______</p>
</div>
- StudentName
- {{ StudentName }}
- { StudentName }
- { _StudentName }
Answer: B) {{ StudentName }}
Explanation:
The code is:
<div ng-app="" ng-init="firstName='John'">
<p>Input something in the input box:</p>
<p>Name: <input type="text" ng-model="StudentName"></p>
<p>You wrote: {{ StudentName }}</p>
</div>
Discuss this Question
22. Consider the below statement – what will be the output?
<div data-ng-app="" data-ng-init="qty=3;price=2.5">
<p>The result is: {{qty * price}}</p>
</div>
- The result is: 7.5
- The result is: 7
- The result is: 7.50
- The result is: 3*2.5
Answer: A) The result is: 7.5
Explanation:
The output of the above statement is: The result is: 7.5
Discuss this Question
23. Consider the below statement – what will be the output?
<div data-ng-app="" data-ng-init="qty=3;">
<p>The result is: {{qty * price}}</p>
</div>
- The result is: Undefined
- The result is: 0
- The result is: 3
- The result is: NaN
Answer: D) The result is: NaN
Explanation:
The output of the above statement is: The result is: NaN
Discuss this Question
24. Consider the below statement – what will be the output?
<div ng-app="" ng-init="cities=['Mumbai','New Delhi','Banglore']">
<p>The cities...</p>
<ul>
<li ng-repeat="c in cities">
{{ c }}
</li>
</ul>
</div>
- Prints the city names in an unordered list
- Prints the city names in an ordered list
- Prints the all name of the city 3 times in an unordered list
- None of the above
Answer: A) Prints the city names in an unordered list
Explanation:
The output will be:
The cities...
- Mumbai
- New Delhi
- Banglore
Discuss this Question
25. Consider the below statement – what will be the output?
<div ng-app="" ng-init="cities=['Mumbai','New Delhi','Banglore']">
<p>The cities...</p>
<ul>
<li ng-repeat="c in cities">
"Hello" {{ c }}
</li>
</ul>
</div>
- Prints the city names with "Hello" in an unordered list
- Prints the city names with "Hello" in an ordered list
- Prints the all name of the city with "Hello" 3 times in an unordered list
- None of the above
Answer: A) Prints the city names with "Hello" in an unordered list
Explanation:
The output will be:
The cities...
- "Hello" Mumbai
- "Hello" New Delhi
- "Hello" Banglore
Discuss this Question
26. Consider the below statement – what will be the output?
<div ng-app="" ng-init="values=[10, 20, 30]">
<p>The value is {{values[0]}}, {{values[3]}}</p>
</div>
- The value is 10, 30
- The value is 10, 0
- The value is 10, NaN
- The value is 10,
Answer: D) The value is 10,
Explanation:
The output will be "The value is 10,". Because array indexing starts with 0 and ends with length of the array -1. In the above statement, there are only 3 elements and the last index is 2. Thus the statement {{values[3]}} will print nothing.
Discuss this Question
27. Consider the below statement – what will be the output?
<div ng-app="" ng-init="values=[10, 20, 30]">
<p>The value is {{values[0]}} + {{values[2]}}</p>
</div>
- The value is 10 + 30
- The value is 40
- The value is NaN
- The value is Undefined
Answer: A) The value is 10 + 30
Explanation:
The output will be "The value is 10 + 30". Here, the addition operation will not be performed it will just print.
Discuss this Question
28. Which AngularJS function creates a new directive?
- .new
- .create
- .directive
- .CreateDirective
Answer: C) .directive
Explanation:
The AngularJS function .directive is used to create new directive.
Discuss this Question
29. Which directive defines the application controller?
- ng-control
- ng-controller
- ng-NewController
- None of the above
Answer: B) ng-controller
Explanation:
The ng-controller directive defines the application controller.
Discuss this Question
30. Filters can be added to expressions by using the ______, followed by a filter.
- comma character (,)
- Colon character (:)
- Hyphen character (-)
- pipe character (|)
Answer: D) pipe character (|)
Explanation:
Filters can be added to expressions by using the pipe character (|), followed by a filter.
Discuss this Question
31. Which AngularJS filter formats a number to a currency format?
- currency
- number
- dollar
- curr
Answer: A) currency
Explanation:
AngularJS currency is used to format a number to a currency format.
Discuss this Question
32. Which AngularJS filter formats a date to a specified format?
- datetime
- time
- date
- ng-date
Answer: C) date
Explanation:
AngularJS date is used to format a date to a specified format.
Discuss this Question
33. Which AngularJS filter selects a subset of items from an array?
- set
- subset
- ng-set
- filter
Answer: D) filter
Explanation:
AngularJS filter filter is used to select a subset of items from an array.
Discuss this Question
34. Which AngularJS filter formats an object to a JSON string?
- ng-json
- json
- set-json
- None of the above
Answer: B) json
Explanation:
AngularJS filter json is used to format an object to a JSON string.
Discuss this Question
35. Which AngularJS filter limits an array/string, into a specified number of elements/characters?
- limitTo
- limit
- ng-limit
- ng-limitTo
Answer: A) limitTo
Explanation:
AngularJS filter limitTo is used to limit an array/string, into a specified number of elements/characters.
Discuss this Question
36. Which AngularJS filter formats a string to lower case?
- lwr
- lower
- lowercase
- ng-lowercase
Answer: C) lowercase
Explanation:
AngularJS filter lowercase is used to format a string to lower case.
Discuss this Question
37. Which AngularJS filter formats a string to upper case?
- upr
- upper
- uppercase
- ng-uppercase
Answer: C) uppercase
Explanation:
AngularJS filter uppercase is used to format a string to upper case.
Discuss this Question
38. Which AngularJS filter formats a number to a string?
- number
- integer
- int
- num
Answer: A) number
Explanation:
AngularJS filter number is used to format a number to a string.
Discuss this Question
39. Which AngularJS filter orders an array by an expression?
- orderby
- orderBy
- order
- OrderBy
Answer: B) orderBy
Explanation:
AngularJS filter orderBy is used to order an array by an expression.
Discuss this Question
40. Which is the correct AngularJS statement to format the value of "studentName" in the uppercase?
- {{ studentName.uppercase }}
- {{ uppercase(studentName) }}
- {{ uppercase.studentName }}
- {{ studentName | uppercase }}
Answer: D) {{ studentName | uppercase }}
Explanation:
The correct AngularJS statement to format the value of studentName in the uppercase is: {{ studentName | uppercase }}
Discuss this Question
41. Which of the following can be used as a prefix for Directive?
- data-
- ng-
- Both A and B
- None of the above
Answer: C) Both A and B
Explanation:
Both data- and ng- can be used a prefix for directive.
Discuss this Question
42. Which is the correct syntax to define multiple filters on an expression?
- {{ expression | filter1 | filter2 | filter3 | ... }}
- {{ expression | {filter1} | {filter2} | {filter3} | ... }}
- {{ expression | {{filter1}} | {{filter2}} | {{filter3}} | ... }}
- {{ expression | filter1 , filter2 , filter3 , ... }}
Answer: A) {{ expression | filter1 | filter2 | filter3 | ... }}
Explanation:
The correct syntax to define multiple filters on an expression is: {{ expression | filter1 | filter2 | filter3 | ... }}
Discuss this Question
43. Which AngularJS service has the set of methods to get the information about the location of the current web?
- $web
- $current
- $location
- All of the above
Answer: C) $location
Explanation:
The AngularJS service $location has methods to get the information about the location of the current web page.
Discuss this Question
44. Which method of $location service is used to get the full URL of the current web page?
- url()
- Url()
- WebUrl()
- absUrl()
Answer: D) absUrl()
Explanation:
The $location.absUrl() returns the full URL of the current web page.
Discuss this Question
45. Which method of $location service is used to get the URL without base prefix?
- url()
- Url()
- WebUrl()
- absUrl()
Answer: A) url()
Explanation:
The $location.url() returns the URL without base prefix.
Discuss this Question
46. Being a JavaScript-only framework, applications written in AngularJS are not safe and secure.
- True
- False
Answer: A) True
Explanation:
The given statement is True.
Discuss this Question
47. Which method of $location service is used to get the current URL without any parameters?
- url()
- absUrl()
- path()
- absPath()
Answer: C) path()
Explanation:
The $location.path() returns the current URL without any parameters.
Discuss this Question
48. Which method of $location service is used to get the search part of the current URL when called without any parameter?
- searchPath()
- absSearch()
- ruleSearch()
- search()
Answer: D) search()
Explanation:
The $location.search() returns the search part of the current URL when called without any parameter.
Discuss this Question
49. Which is not a valid method of $location service?
- hostname()
- host()
- path()
- hash()
Answer: A) hostname()
Explanation:
There is no function named hostname() in $location service.
Discuss this Question
50. Which AngularJS service is used to make the request to the server?
- $https
- $request
- $http
- $requests
Answer: C) $http
Explanation:
The Angular service $http is used to make a request to the server.
Discuss this Question
51. Which AngularJS service is the version of the window.setTimeout function?
- $timeout
- $WindowTimeout
- $WinTimeout
- $setTimeout
Answer: A) $timeout
Explanation:
The AngularJS service $timeout is the version of the window.setTimeout function.
Discuss this Question
52. Which AngularJS service is the version of the window.setInterval function?
- $interval
- $WindowInterval
- $WinInterval
- $setInterval
Answer: A) $interval
Explanation:
The AngularJS service $interval is the version of the window.setInterval function.
Discuss this Question
53. AngularJS is entirely based on HTML and JavaScript?
- True
- False
Answer: A) True
Explanation:
It's true that – AngularJS is entirely based on HTML and JavaScript.
Discuss this Question
54. Can we create custom directives in AngularJS?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, we can create custom directories in AngularJS.
Discuss this Question
55. In AngularJS, what is the data binding?
- Synchronization between controller part and view part
- Synchronization between model part and controller part
- Synchronization between model part and view part
- None of the above
Answer: C) Synchronization between model part and view part
Explanation:
Data binding is the synchronization between model part and view part in AngularJS.
Discuss this Question
56. Which AngularJS directive is used to bind AngularJS application data to the disabled attribute of HTML elements?
- ng-disabled
- ng-disable
- ng-disabledElement
- ng-disableElement
Answer: A) ng-disabled
Explanation:
The ng-disabled directive is used to bind AngularJS application data to the disabled attribute of HTML elements.
Discuss this Question
57. Which AngularJS directive is used to show or hide an HTML element?
- ng-showHide
- ng-ShowHide
- ng-show
- ng-hide
Answer: C) ng-show
Explanation:
The ng-show directive is used to show or hide an HTML element.
Discuss this Question
58. Which AngularJS directive is used to hide or show an HTML element?
- ng-showHide
- ng-ShowHide
- ng-show
- ng-hide
Answer: D) ng-hide
Explanation:
The ng-hide directive is used to hide or show an HTML element.
Discuss this Question
59. Which AngularJS directive is used to define AngularJS code that will be executed when the element is being clicked?
- ng-click
- ng-mouseOver
- ng-mouseClick
- ng-mouse
Answer: A) ng-click
Explanation:
The ng-click directive is used to define AngularJS code that will be executed when the element is being clicked.
Discuss this Question
60. Which is the correct syntax of AngularJS directive ng-show?
- ng-show:"true/false"
- ng-show="true/false"
- ng-app ng-show="true/false"
- None of the above
Answer: B) ng-show="true/false"
Explanation:
The syntax of AngularJS directive ng-show is: ng-show="true/false"
Discuss this Question
61. Consider the below statement – what will be the output?
<div ng-app="" ng-init="num=10">
<p ng-show="num > 5">Displaying: {{num}}</p>
</div>
- Syntax Error
- Nothing will display
- Displaying: 5
- Displaying: 10
Answer: D) Displaying: 10
Explanation:
In the above code, the expression is evaluated with the ng-show which is valid with AngularJS. Thus, the output will be "Displaying: 10".
Discuss this Question
62. The $event object contains the ______.
- browser's event object
- browser's current path
- Both A. and B.
- None of the above
Answer: A) browser's event object
Explanation:
The $event object contains the browser's event object.
Discuss this Question
63. Which module routes your application to different pages without reloading the entire application?
- ngRoutes
- route
- ng-Route
- ngRoute
Answer: D) ngRoute
Explanation:
The ngRoute module routes your application to different pages without reloading the entire application.
Discuss this Question
64. Which of the below is an Invalid filter in AngularJS?
- JSON
- limitTo
- orderBy
- email
Answer: D) email
Explanation:
The email is an invalid filter in AngularJS.
Discuss this Question
65. The .subscribe in AngularJS is used for?
- Streams data synchronously
- Streams data asynchronously
- Both of the above
- None of the above
Answer: C) Both of the above
Explanation:
The .subscribe is used for the both:
- Streams data synchronously
- Streams data asynchronously
Discuss this Question