AngularJS - Quiz - Jan 2016

Description

AngularJS Quiz
arunram.krish
Quiz by arunram.krish, updated more than 1 year ago
arunram.krish
Created by arunram.krish about 8 years ago
928
0

Resource summary

Question 1

Question
How do you create an AngularJS module 'myApp' that is dependent on the modules "myApp.c", "myApp.s","myApp.f" and "myApp.d"?
Answer
  • var myApp = angular.createModule("myApp") .inject("myApp.c", "myApp.s","myApp.f" ,"myApp.d");
  • var myApp = angular.module("myApp") .inject("myApp.c", "myApp.s","myApp.f" ,"myApp.d");
  • var myApp = angular.module("myApp", ["myApp.c", "myApp.s","myApp.f" ,"myApp.d"]);
  • var myApp = angular.module("myApp", "myApp.c", "myApp.s","myApp.f" ,"myApp.d");

Question 2

Question
What are the 5 recipe types apart from the special recipes to create components in AngularJS module?
Answer
  • Value, Factory, Service, Provider, Constant
  • Singleton, Factory, Service, Provider, Literal
  • Singleton, Module, Service, Provider, Constant
  • Value, Builder, Prototype, Provider, Constant

Question 3

Question
What is the name the directive that is used to initialize angularJS application?
Answer
  • ngView
  • ngModule
  • ngRoute
  • ngApp

Question 4

Question
In which AngularJS special component do you place the logic to manipulate DOM?
Answer
  • controller
  • directive
  • filter
  • service

Question 5

Question
Which function should I invoke to refresh the view, if I modify an attribute in the angular scope outside angularJS context?
Answer
  • angular.refresh();
  • scope.refresh();
  • controller.apply();
  • scope.apply();

Question 6

Question
What are the phases in AngularJS’ HTML compilation and what is done in each phase?
Answer
  • Bootstrap: Loads angular application module, with all its dependent modules along with ngCore modules Execute: Executes HTML view created after compilation
  • Compile: Compiles HTML template to create AngularJS view with binding Execute: Executes AngularJS view listening to DOM events for triggers
  • Compile: Identifies / matches directives in HTML DOM Sort: Sorts directives based on priority and a combined link function is created Link: Links specific instance of scope to template, registers listeners on DOM elements, sets up required $watch with the scope
  • Bootstrap: Loads angular application module, with all its dependent modules along with ngCore modules Link: Links specific instance of scope to template, registers listeners on DOM elements, sets up required $watch with the scope

Question 7

Question
Which of the following ways is /are INCORRECT to create an AngularJS controller in the AngularJS module – “appModule” – dependent on components registered with following names – svc, $scope, $http, myValue, myConstant?
Answer
  • var myController = appModule.controller(“myController”, [“svc”, “$scope”, “$http”, “myValue”, “myConstant”, function(svc, $scope, $http, myValue, myConstant) { //TODO define controller’s constructor body here }]);
  • var MyController = function(svc, $scope, $http, myValue, myConstant) { //TODO define controller’s constructor body here }; MyController.$inject([“svc”, “$scope”, “$http”, “myValue”, “myConstant”]); appModule.controller(“myController”,MyController);
  • var myController = appModule.controller(“myController”, function(svc, $scope, $http, myValue, myConstant) { //TODO define controller’s constructor body here };
  • var myController = appModule.controller(“myController”, function() { var svc = appModule.lookup(“svc”); var $scope = appModule.lookup(“$scope”); var $http = appModule.lookup(“$http”); var myValue = appModule.lookup(“myValue”); var myConstant = appModule.lookup(“myConstant”); //TODO define controller’s constructor body here };

Question 8

Question
Which of the following statements are CORRECT about AngularJS scope?
Answer
  • AngularJS creates a $rootScope when it encounters ngApp directive in the loaded HTML template.
  • AngularJS scopes are hierarchical where in child scope inherit from its parent scope through prototype chain
  • All AngularJS scopes including “isolated” scope inherits prototypically from its parent scope
  • Scope provides $apply to watch model change and $watch to propagate model changes from outside “Angular realm”

Question 9

Question
Where all can we place AngularJS directive?
Answer
  • Only elements
  • Only attributes
  • Only CSS styles
  • Only Comments
  • All of the above

Question 10

Question
How do you initialize / configure AngularJS $route module? Choose the wrong option from the following list
Answer
  • //no need to download angular-route separately as it is part of ngCore <script> var appModule = angular.module("myapp",['ngRoute']); appModule.map($route, “myURL1”, “partials/myPartial1.html”, partial1Controller); //TODO map remaining URLs </script>
  • <script src="bower_components/angular-route/angular-route.js"></script> <script> var appModule = angular.module("myapp",['ngRoute']); appModule.config(['$routeProvider', function($routeProvider) { //TODO configure route with URL mapping }]); </script>
  • <script src="bower_components/angular-route/angular-route.js"></script> <script> var appModule = angular.module("myapp",['ngRoute']); $route.$inject(['$routeProvider', function($routeProvider) { //TODO configure route with URL mapping }]); </script>
  • <script src="bower_components/angular-route/angular-route.js"></script> <script> var appModule = angular.module("myapp",['ngRoute']); $route.$inject(['urlMappings', {“url1” : {“partial1.html” : “url1template.html”, “controller”: url1Controller}, “url2” : {“partial2.html” : “url2template.html”, “controller”: url2Controller} } ]); </script>

Question 11

Question
When do you use AngularJS filters?
Answer
  • Sorting a list of javascript objects based on a property in the object
  • Displaying a text in the selected language
  • Convert <div> element to <span> element
  • Filter DOM elements based on CSS selector

Question 12

Question
When is it recommended to use AngularJS provider?
Answer
  • Reusable component that needs to be configured before it can be injected into other angular JS components
  • Component to manipulate your URL
  • Component to interact with HTTP server
  • All of the above

Question 13

Question
Which AngularJS components provides APIs for AJAX and JSONP?
Answer
  • $ajax
  • $resource
  • $jsonp
  • $http

Question 14

Question
Which of the following options best describe Karma framework?
Answer
  • Karma records user interactions on the browser and can be replayed
  • Karma is a command-line javascript test runner in which any of the testing framework can be plugged in to execute test cases
  • Karma is a testing framework that provides APIs to test Angular JS components
  • Karma is a browser plugin to debug and test AngularJS application

Question 15

Question
How do you inject a custom Angular scope object into an Angular JS controller “MyController” using ngMock and Jasmine API inside beforeEach ?
Answer
  • var scope; beforeEach(function(){ module('appModule'); inject(function($controller, $rootScope){ scope = $rootScope.$new(); $controller('MyController',{$scope:scope}); }); //TODO set state in scope });
  • var scope; beforeEach(function(){ module('appModule'); var myController = angular.controller(“MyController”, [“scope”, function($scope){ //TODO set state in scope }]); });
  • var scope; beforeEach(function(){ module('appModule'); angular.controller(‘MyController’). inject(function($rootScope){ scope = $rootScope.$new(); //TODO set state in scope }); });
  • var scope; beforeEach(function(){ module('appModule'); var myController = angular.controller(“MyController”); myController.$inject([“scope”]); });
Show full summary Hide full summary

Similar

Front-End Web Development
Chanthy Ngin
Angular Nuts and Bolts
James Drummond
AngularJS
Akhil Sree Nivas
Directives, compile and link
James Drummond
How Angular works
James Drummond
SAT Exam 'Word of the Day' Set 2
SAT Prep Group
GCSE English Literature: Of Mice and Men
mia.rigby
A-level Psychology Key Terms & Definitions
Andrea Leyden
BIOLOGY HL DEFINITIONS IB
Luisa Mandacaru
An Inspector Calls: Sheila Birling
Rattan Bhorjee
MAPA MENTAL DISEÑO GRAFICO
puntoideascali