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