MCQs > IT & Programming > Angular JS MCQs > Basic Angular JS MCQs

Basic Angular JS MCQ

1. What is an alternative way to write this markup to bind the value of the class field userName to the h1 element title property?

Current user is {{ userName }}

Answer

Correct Answer: title="{{ userName }}"

Note: This Question is unanswered, help us to find answer for this one

2. How does the emulated view encapsulation mode handle CSS for a component?

Answer

Correct Answer: It creates unique attributes for DOM elements and scopes the CSS selectors you write to those attribute ids.

Note: This Question is unanswered, help us to find answer for this one

3. In reactive forms, what Angular form class type is used on the native DOM element to wire it up?

Answer

Correct Answer: FormGroup

Note: This Question is unanswered, help us to find answer for this one

4. When a service is provided for root and is also added to the provider's configuration for a lazy-loaded module, what instance of that service does the injector provide to constructors in the lazy-loaded module?

Answer

Correct Answer: A new instance of that service is created when the module is lazy loaded.

Note: This Question is unanswered, help us to find answer for this one

5. In order for Angular to process components in an application, where do the component types need to be registered?

Answer

Correct Answer: In an NgModule decorator metadata property named declarations

Note: This Question is unanswered, help us to find answer for this one

6. What is the purpose of the data property (seen in the example below) in a route configuration? {path: 'customers', component: CustomerListComponent, data: { accountSection: true }}

Answer

Correct Answer: A way to include static, read-only data associated with the route that can be retrieved from the ActivatedRoute

Note: This Question is unanswered, help us to find answer for this one

7. What is the difference, if any, of the resulting code logic based on these two provider configurations? [{ provide: FormattedLogger, useClass: Logger }][{ provide: FormattedLogger, useExisting: Logger }];

Answer

Correct Answer: The useClass syntax tells the injector to make a new instance of Logger and bind that instance to the FormattedLogger token. The useExisting syntax refers to an already existing object instance declared as Logger.

Note: This Question is unanswered, help us to find answer for this one

8. What is the value type that will be stored in the headerText template reference variable in this markup?

User List

Answer

Correct Answer: An Angular ElementRef, a wrapper around a native element

Note: This Question is unanswered, help us to find answer for this one

9. What Angular template syntax can you use on this template-driven form field to access the field value and check for validation within the template markup?

Answer

Correct Answer: You can make use of a template reference variable and the exportAs feature that the ngModel directive has.

Note: This Question is unanswered, help us to find answer for this one

10. How would you configure a route definition for a UserDetailComponent that supports the URL path user/23 (where 23 represents the id of the requested user)?

Answer

Correct Answer: { path: 'user/:id', component: UserDetailComponent }

Note: This Question is unanswered, help us to find answer for this one

11. Pick the best description for this template syntax code: Boss: {{job?.bossName}}

Answer

Correct Answer: It is using the safe navigation operator (?) on the job field. If the job field is undefined, the access to the bossName will be ignored and no error will occur.

Note: This Question is unanswered, help us to find answer for this one

12. What are Angular lifecycle hooks?

Answer

Correct Answer: Reserved named methods for components and directives that Angular will call during set times in its execution, and can be used to tap into those lifecycle moments

Note: This Question is unanswered, help us to find answer for this one

13. You want to see what files would be generated by creating a new contact-card component. Which command would you use?

Answer

Correct Answer: Ng generate component contact-card --dry-run

Note: This Question is unanswered, help us to find answer for this one

15. What is the purpose of the valueChanges method on a FormControl?

Answer

Correct Answer: It is an observable that emits every time the value of the control changes, so you can react to new values and make logic decisions at that time.

Note: This Question is unanswered, help us to find answer for this one

16. What are the two component decorator metadata properties used to set up CSS styles for a component?

Answer

Correct Answer: Styles and styleUrls.

Note: This Question is unanswered, help us to find answer for this one

17. What is the RouterModule.forRoot method used for?

Answer

Correct Answer: Registering route definitions at the root application level.

Note: This Question is unanswered, help us to find answer for this one

18. What is the difference between the paramMap and the queryParamMap on the ActivatedRoute class?

Answer

Correct Answer: Both are Observables containing values from the requested route's URL string. The paramMap contains the parameter values that are in the URL path and the queryParamMap contains the URL query parameters.

Note: This Question is unanswered, help us to find answer for this one

19. What method is used to wire up a FormControl to a native DOM input element in reactive forms?

Answer

Correct Answer: Use the formControlName directive and set the value equal to the string name given to the FormControl.

Note: This Question is unanswered, help us to find answer for this one

20.

Which line often given code contains the attribute that tells which part of the HTML contains the AngularJS app?



Answer

Correct Answer:

Line 5 


Note: This Question is unanswered, help us to find answer for this one

21. In AngularJS, every bookmarkable URL is called a:

Answer

Correct Answer: Route

Note: This Question is unanswered, help us to find answer for this one

22.

it is given that pagination is implemented to browse the menu of a shopping website implemented in AngularJS. For the click

event on the next-page button, how would you implement the change of URL? [Take the URL as www.xxx.com#?page=2]


Answer

Correct Answer:

var current = $location.search[){'page'];

$location.search(‘page'. current + 1): 



Note: This Question is unanswered, help us to find answer for this one

23.

It is given that the command. var app = anguianmoduiefMyMainApp'. ['moduie1'. 'moduie2']. was used to inject certain modules as a dependency to the main module. These ng—app modules were developed for a web page.

Answer

Correct Answer:

it will expose both the controllers and directives of the dependency to the MyMainApp scope.


Note: This Question is unanswered, help us to find answer for this one

24. Which AngularJS directive is used to bind data values of an AngularJS application to HTML input controls?

Answer

Correct Answer: ng-model

Note: This Question is unanswered, help us to find answer for this one

25.

I) ng-app="module"

ii) $injector

iii) $compile

iv) $rootScope

From the options given below. choose the one that describes what occurs during auto-bootstrapping of an angular application.


Answer

Correct Answer:

i) invokes ii).

ii) invokes iii) and iv).



Note: This Question is unanswered, help us to find answer for this one

26. Which directive is used to define the variables to be used in an AngularJS application?

Answer

Correct Answer: ng-model

Note: This Question is unanswered, help us to find answer for this one

27. The ngChange directive in AngularJS executes at:

Answer

Correct Answer: Priority level 0.

Note: This Question is unanswered, help us to find answer for this one

28. Which of the services given below parses the Uniform Resource Locator (URL) in the address bar of the browser and makes that URL available to the application?

Answer

Correct Answer: $location

Note: This Question is unanswered, help us to find answer for this one

29. When $http.get returns a particular object. what method does this object invoke when getting the response?

Answer

Correct Answer: then

Note: This Question is unanswered, help us to find answer for this one

30. in Service Fabric [PowerShell). which of the following commands is used to retrieve me status of each node available in a cluster?

Answer

Correct Answer: Get-ServiceFabricCIUSterHealth

Note: This Question is unanswered, help us to find answer for this one

31. Which of the functions given below is used for serializing common angular objects into strings?

Answer

Correct Answer: angular.mock.dump

Note: This Question is unanswered, help us to find answer for this one

32. What is the most ideal and professional approach to store variables in a controller, which you want to later access in another controller?

Answer

Correct Answer: None of the above serves the required case.

Note: This Question is unanswered, help us to find answer for this one

33.


The AngularJS code shown in Figure 1 of the image was supposed to give the output shown in Figure 2 but is giving a different output Which of the following code lines should be modif‌ied to obtain the required output?

Answer

Correct Answer:

Line 16


Note: This Question is unanswered, help us to find answer for this one

34.

Which of the following statements is/are lNCORRECT about the angular.extend function?

1. You cannot specify more than one src object in this function.

2. You can pass an empty object as the target to preserve the original objects.

3. This function does not support recursive merge.


Answer

Correct Answer:

Only1 is incorrect 


Note: This Question is unanswered, help us to find answer for this one

35.

Which of the statements given below is/are correct about the ngApp directive?

1. You can auto-bootstrapp only one AngularJS application per HTML document.

2. No AngularJS module can be specif‌ied to be used as the root module for the application.

3. You can nest one AngularJS application within another AngularJS application.


Answer

Correct Answer:

0nly1 


Note: This Question is unanswered, help us to find answer for this one

36. Which of the following directives is NOT supported by the ngAria module?

Answer

Correct Answer: ngRepeat

Note: This Question is unanswered, help us to find answer for this one

37. A bootstrap event of AngularJS is f‌ired in a single page application. In this situation, how many ng-app directives will be processed?

Answer

Correct Answer: 1

Note: This Question is unanswered, help us to find answer for this one

38.

in Distributed Architecture Structure, which of the following statements about the service layer are correct?

1. The service layer is used to identify and manage the types of services that can be offered.

2. It directly communicates to the resource manager to validate the type of service required by a user.

3. it is not responsible for updating about the resource availability.


Answer

Correct Answer:

Both statements1 and 2 are correct.


Note: This Question is unanswered, help us to find answer for this one

39.

Consider the AnguiarJS code given in Flgure1 of the image. Which of the following should replace the “??' symbol in the form tag so as to obtain the output shown in Figure 2

Answer

Correct Answer:

<select ng-model=”myf=orm.nm‘ ng~options=”obj.id as obj.name for obj in myi—‘orm.options" > </select> 


Note: This Question is unanswered, help us to find answer for this one

40. How many child scopes can an AngularJS application have?

Answer

Correct Answer: Any number

Note: This Question is unanswered, help us to find answer for this one

41. The value of the query parameter P (value: X) in a URL has to be changed to X + 2. Minimum how many times should the search method of the $location service be used to achieve this functionality?

Answer

Correct Answer: 2

Note: This Question is unanswered, help us to find answer for this one

42.

var MainControlier = function($scope)

i

var person =[

f‌irstName : "Sunny‘,

lastName : "Kumar”,

Src : "localhost/mytest.png"

];

Analyze the given code snippet Which of the following statements is incorrect about the above code snippet?


Answer

Correct Answer:

person acts as a model to the scope object. 


Note: This Question is unanswered, help us to find answer for this one

43.

Analyze the AngularJS code given in Figure 1 of the image. and choose its correct output from the options given in Figure 2.

Answer

Correct Answer:

(e)


Note: This Question is unanswered, help us to find answer for this one

44. $routeProvider can be conf‌igured by calling which of the following functions?

Answer

Correct Answer: otherwise()
when()

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

45.

Which of the following statements is/are TRUE about directives in AngularJS?

1. Custom HTML tags can be created using directives.

2. Directives are functions bound to a particular scope.

3. Directives are singleton objects that can be instantiated only once in an application.


Answer

Correct Answer:

Only1 


Note: This Question is unanswered, help us to find answer for this one

46. Which of the following can be used to add/remove HTML elements from the DOM. based on the data in the model?

Answer

Correct Answer: ng-switch directive
ng-if directive

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

47. Which of the following are correct about AngularJS?

Answer

Correct Answer: It allows adding custom directives.
It supports dependency injection.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

48. Which of the following statements is/are true about AngularJS?

Answer

Correct Answer: It supports both client and server communication.

Note: This Question is unanswered, help us to find answer for this one

49. In which of the following does Angular provide the RESTful functionality?

Answer

Correct Answer: ngResource module

Note: This Question is unanswered, help us to find answer for this one

50. Which of the following methods is NOT used by $compileProvider?

Answer

Correct Answer: register(name. factory);

Note: This Question is unanswered, help us to find answer for this one

51.

Consider the AngularJS code given in Figure1 of the image. Which of the following should replace the "??‘ symbol shown in the script tag so as to obtain the output shown in Figure 2?

Answer

Correct Answer:

anguiacmodulefappf‌l D)
.controller('xyz", function($scope)(
$scope.myForm = f‌l;
SscopemyFormf‌irstName = "Kevin":
SscopemyFormJastName = "O'Brien”;
1);  



Note: This Question is unanswered, help us to find answer for this one

52.

in a gaming application of Service Fabric. which of the following statements about actors are correct?

1. Actors are used to create new user prof‌iles. send chat messages. or trade items between the players.

2. Adding more different actor types allow us to scale parts of our backend up and down with higher granularity.

3. The number of division of actors is restricted in the Service Fabric application.


Answer

Correct Answer:

Both statements 1 and 2 are correct.


Note: This Question is unanswered, help us to find answer for this one

53. Which of the following options is NOT a built-in f‌ilter component used in AngularJS?

Answer

Correct Answer: time

Note: This Question is unanswered, help us to find answer for this one

54.

<d1>

    <d2></d2>

    <d3>

           <d4><fd4>

     </d3>

</d1>

d1. d2. d3 and d4 are AngularJS directives. Find the order in which the post-link event of these directives lifecycle occurs.


Answer

Correct Answer:

d2. d4. d3. D1


Note: This Question is unanswered, help us to find answer for this one

55. Which of the following can be used to associate controllers with scope objects implicitly?

Answer

Correct Answer: ngController directive
$route service

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

56.

Which part of the MVC architecture holds an application's data and def‌ines the logic that manages that data?

Answer

Correct Answer: Model

Note: This Question is unanswered, help us to find answer for this one

57. The GET method using the HTTP service fails to receive a response from the server. How will the AngularJS application react to this scenario?

Answer

Correct Answer: The method waiting for the response may redirect it to the error-handling function.

Note: This Question is unanswered, help us to find answer for this one

58.

in Service Fabric. which of the following statements about the guest executable are correct?

1. it is an existing, arbitrary executable that can be run as a service in an application.

2. it is used to call the Service Fabric SDK APis directly.

3. It contains the lifecycle support during the whole application.


Answer

Correct Answer:

Both statements 1 and 3 are correct


Note: This Question is unanswered, help us to find answer for this one

59. At which priority level does the nglf directive execute?

Answer

Correct Answer: Priority level 600

Note: This Question is unanswered, help us to find answer for this one

60.

You are given a nested Directive Structure. Suppose that the parent node. on receiving the data. broadcasts the information to render to its child directives. How will the broadcast be emitted and received within the parent scope?


Answer

Correct Answer:

emit - $scope.$broadcastfrender’. data)

receive - $scope.$on(‘render', function(data)[]) 



Note: This Question is unanswered, help us to find answer for this one

61. Which of the services indicated below provides primitive DOM manipulation functions to insert, remove as well as move elements within the DOM?

Answer

Correct Answer: $animate

Note: This Question is unanswered, help us to find answer for this one

62. Which directive executes at priority level 1000?

Answer

Correct Answer: ngRepeat

Note: This Question is unanswered, help us to find answer for this one

63. Which service does the HTML $compile service use for the purpose of data binding?

Answer

Correct Answer: $f‌ilter
$interpolate

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

64. Which directive works exactly like the ngClassOdd and ngClassEven directives except that while it works individually, the last two work together with the ngRepeat directive?

Answer

Correct Answer: ngClass

Note: This Question is unanswered, help us to find answer for this one

65. Which of the following symbols can be used to add f‌ilters to directives?

Answer

Correct Answer: L

Note: This Question is unanswered, help us to find answer for this one

66.

Which of the following sentences is correct about the following code snippet?

A) The last line of the code will evaluate to false.

B) Scopes do not follow inheritance, i.e. "c" will not inherit the scope of “p".
var p = $rootScope:

var c = p.$new();

p.salutation = "Sir";

expect(c.salutation).toEqual('Sir‘);

Answer

Correct Answer:

Statements A and B are false.


Note: This Question is unanswered, help us to find answer for this one

67.

Which of the following options is the function of the given Service Fabric CLI command?

sfcti node list --query "sort_by(items{‘]. &name)[-1].name


Answer

Correct Answer:

Retrieve the node-name value of the last created node.


Note: This Question is unanswered, help us to find answer for this one

68. Consider that you are creating a Service Fabric CLI application. You are unable to view the build definition template. Which of the following options is considered as the major reason behind the given condition?

Answer

Correct Answer: Newly created YAML pipeline creation experience feature is turned on.

Note: This Question is unanswered, help us to find answer for this one

69.

What will be the output of the AngularJS code given below?

Answer

Correct Answer:

Statement1 - 20.5

Statement2 - 15.5

Statement3 - 20.5

Statement4 - 25.5 



Note: This Question is unanswered, help us to find answer for this one

70.

What will be the output of the given AngularJS code?

Answer

Correct Answer:

AngularJS

78,93,71,79,68



Note: This Question is unanswered, help us to find answer for this one

71. Which of the following services helps run functions asynchronously?

Answer

Correct Answer: $q

Note: This Question is unanswered, help us to find answer for this one

72. Which of the following functions return chaining when used as setters?

Answer

Correct Answer: hashPrefix([prefix]);
debuglnfoEnabled(enabledI);

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

73.

State whether the following statement is True or False:

The $scope.$watch() and $scope.$digest() functions are automatically called by AngularJS; they cannot be called manually.


Answer

Correct Answer:

False 


Note: This Question is unanswered, help us to find answer for this one

74. if the HTML template display causes a f‌lickering effect in an AngularJS application, which directive can be used to avoid that effect?

Answer

Correct Answer: ngCloak

Note: This Question is unanswered, help us to find answer for this one

75. in AngularJS. what is the function of the scope object that is available in the MVC pattern?

Answer

Correct Answer: It detects and broadcasts changes to the state of an application.

Note: This Question is unanswered, help us to find answer for this one

76.

What will be the output of the given AngularJS code?

Answer

Correct Answer:

GLENN MAXWELL

fee: $455.00

0 C language, marksz77

0 Java language, marks:87

0 Python language. Marks:67 



Note: This Question is unanswered, help us to find answer for this one

77.

Which of the following statements about the parts of AngularJS frameworks are correct?

1. ng-app def‌ines and links an AngularJS application to HTML.

2. ng-model binds the values of AngularJS application data to a cloud model.

3. ng-bind binds the AngularJS application data to HTML tags.


Answer

Correct Answer:

Both 1 and 3 


Note: This Question is unanswered, help us to find answer for this one

78. Which of the following is NOT a property of the angular.version object?

Answer

Correct Answer: codelD

Note: This Question is unanswered, help us to find answer for this one

79.

Consider that you are building a shopping cart application by using AngularJS. Which of the following statements about the given code snippet are correct?

<div class="right">

<i class="fa fa-check" ng-show="!item_striken$index" ng-click='item_striken$index =

titem_striken$index"></i>

<i class="fa fa-times" ng-show="item_striken$index" ng-click="item_striken$index =

litem_striken$index"></i>

<i class="fa fa-trash“ ng-click="de|eteltem($index)"></i>

</div>

1. The item_striken$index instance denotes each item in the list. Here, the index refers to the index of the array. This is the index that we passed to delete the function earlier.

2. The ng-show directive shows or hides the element based on the given condition. The value of the item_striken$index instance changes on click. Based on true or false, tick or cross is displayed.

3. In span, the ng-class:"[striken : item_striken$index]” statement will add the striken class to span, if item_striken$index is false.


Answer

Correct Answer:

Both 1 and 2


Note: This Question is unanswered, help us to find answer for this one

80.

In Distributed Architecture Structure, which of the following groups undergoes conf‌iguration by using the scope?

1. Global

2. Environment-specif‌ic

3. Service-specif‌ic

4. Instance-specif‌ic


Answer

Correct Answer:

All 1. 2, 3, and 4 


Note: This Question is unanswered, help us to find answer for this one

81. is it possible to create nested scopes that do not inherit properties from their parent scopes?

Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

82.

The given code snippet adds properties in a controller. How will you refer to a property named. BusinessObject. in the view or front-end under an <h1><h1> HTML tag?

var app = angular.modu|e('yourApp', []);

app.controller(‘yourController‘. function(i$scope) [

$scope.BusinessObject = 'Business Object";);


Answer

Correct Answer:

<h1>[{BusinessObject]]</h1>  


Note: This Question is unanswered, help us to find answer for this one

83.

The following snippet is used in an HTML f‌ile to insert the angular.js framework f‌ile:

"