This is a timed quiz.
You have 30 minutes to complete the 15 questions in this quiz.
How do you create an AngularJS module 'myApp' that is dependent on the modules "myApp.c", "myApp.s","myApp.f" and "myApp.d"?
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");
What are the 5 recipe types apart from the special recipes to create components in AngularJS module?
Value, Factory, Service, Provider, Constant
Singleton, Factory, Service, Provider, Literal
Singleton, Module, Service, Provider, Constant
Value, Builder, Prototype, Provider, Constant
What is the name the directive that is used to initialize angularJS application?
ngView
ngModule
ngRoute
ngApp
In which AngularJS special component do you place the logic to manipulate DOM?
controller
directive
filter
service
Which function should I invoke to refresh the view, if I modify an attribute in the angular scope outside angularJS context?
angular.refresh();
scope.refresh();
controller.apply();
scope.apply();
What are the phases in AngularJS’ HTML compilation and what is done in each phase?
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
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?
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 };
Which of the following statements are CORRECT about AngularJS scope?
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”
Where all can we place AngularJS directive?
Only elements
Only attributes
Only CSS styles
Only Comments
All of the above
How do you initialize / configure AngularJS $route module? Choose the wrong option from the following list
//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>
When do you use AngularJS filters?
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
When is it recommended to use AngularJS provider?
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
Which AngularJS components provides APIs for AJAX and JSONP?
$ajax
$resource
$jsonp
$http
Which of the following options best describe Karma framework?
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
How do you inject a custom Angular scope object into an Angular JS controller “MyController” using ngMock and Jasmine API inside beforeEach ?
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”]); });