AngularJS Descriptive Questions for exam (part-1)

AngularJS Descriptive Questions for exam (part-1)
idb bishew question


1. What is Routing in AngularJS?


Answer: AngularJS Routing helps you to divide your app into multiple views and bind different views to Controllers. The magic of Routing is taken care by an AngularJS service $routeProvider. $routeProvider service provides method when() and otherwise() to define the routes for your app. Routing has dependency on ngRoute module.
2. What methods $resource service object support?

Answer: The $resource service object supports the following methods:
1. get()
2. query()
3. save()
4. remove()
5. delete()
3. How to enable caching in $http service?

Answer: You can enable caching in $http service by setting configuration property cache to true. When cache is enabled, $http service stores the response from the server in local cache. In this way, next time the response will be served from the cache without sending request to server.
1.    $http.get("http://server/myserviceapi",{cache:true}).sucess(function(){
2.     
3.    //TO DO:
4.     
5.    });
4. What methods $http service support?

Answer: The $http service supports the following methods:
1. $http.get()
2. $http.head()
3. $http.post()
4. $http.put()
5. $http.delete()
6. $http.jsonp()
7. $http.patch()
5. What is the difference between $http and $resource?

Answer: $http service is a core Angular service which allows you to make AJAX requests by using GET, HEAD, POST, PUT, DELETE, JSONP and PATCH methods. It is very much like the $.ajax() method in jQuery. It can be used with RESTful and Non-RESTful server-side data sources.

$http is good for quick retrieval of server-side data that doesn’t really need any specific structure or complex behaviors.

$resource warps $http and allows you to interact with RESTful server-side data sources. It requires the ngResource module to be installed which exist in angular-resource.js

$http is good for retrieval of RESTful server-side data sources that might need any specific structure or complex behaviors.
6. What is the difference between Factory, Service and Provider?

Answer: Factory - A factory is a simple function which allows you to add some logic before creating the object. It returns the created object.

When to use: It is just a collection of functions like a class. Hence, it can be instantiated in different controllers when you are using it with constructor function.

Service - A service is a constructor function which creates the object using new keyword. You can add properties and functions to a service object by using this keyword. Unlike factory, it doesn’t return anything.

When to use: It is a singleton object. Use it when you need to share a single object across the application.
For example, authenticated user details.

Provider - A provider is used to create a configurable service object. It returns value by using $get() function.

When to use: When you need to provide module-wise configuration for your service object before making it available.
7. What are different ways to create service in AngularJS?

Answer: There are five ways to create a service as given below:
1. Service
2. Factory
3. Provider
4. Value
5. Constant
8. What is Service in AngularJS?

Answer: A service is a reusable singleton object which is used to organize and share code across your app. A service can be injected into controllers, filters, directives.

AngularJS offers several built-in services (like $http, $provide, $resource, $window, $parse) which always start with $ sign.


9. What is View in AngularJS?

Answer: The view is responsible for presenting your models data to end user. Typically it is the HTML markup which exists after AngularJS has parsed and compiled the HTML to include rendered markup and bindings.
10. What is Controller in AngularJS?

Answer: The controller defines the actual behavior of your app. It contains business logic for the view and connects the model to view with the help of $scope. A controller is associated with a HTML element with the ng-controller directive.
11. What is ViewModel in AngularJS?

Answer: A viewmodel is an object that provides specific data and methods to maintain specific views. Basically, it is a $scope object which lives within your AngularJS app's controller. A viewmodel is associated with a HTML element with the ng-model and ng-bind directives.
12. What is Model in AngularJS?

Answer: Models are plain old JavaScript objects that represent data used by your app. Models are also used to represent your app's current state.
13. Does AngularJS support MVC?

Answer: AngularJS is a MVC framework. It does not implement MVC in the traditional way, but rather something closer to MVVM Model-View-ViewModel).
14. How AngularJS handle data binding?

Answer: AngularJS handle data-binding mechanism with the help of three powerful functions: $watch(), $digest() and $apply(). Most of the time AngularJS will call the $scope.$watch() and $scope.$digest() functions for you, but in some cases you may have to call these functions yourself to update new values.
15. Explain Two-way and One-way data binding in AngularJS?

Answer: Two-way data binding - It is used to synchronize the data between model and view. It means, any change in model will update the view and vice versa. ng-model directive is used for two-way data binding.

One-way data binding - This binding is introduced in Angular 1.3. An expression that starts with double colon (::), is considered a one-time expression i.e. one-way binding.
16. What is data binding in AngularJS?

Answer: AngularJS data-binding is the most useful feature which saves you from writing boilerplate code (i.e. the sections of code which is included in many places with little or no alteration). Now, developers are not responsible for manually manipulating the DOM elements and attributes to reflect model changes. AngularJS provides two-way data-binding to handle the synchronization of data between model and view.


17. What is $scope and $rootScope?
Answer: $scope - A $scope is a JavaScript object which is used for communication between controller and view. Basically, $scope binds a view (DOM element) to the model and functions defined in a controller.

$rootScope - The $rootScope is the top-most scope. An app can have only one $rootScope which will be shared among all the components of an app. Hence it acts like a global variable. All other $scopes are children of the $rootScope.
18. What is scope in AngularJS?


Answer: Scope is a JavaScript object that refers to the application model. It acts as a context for evaluating angular expressions. Basically, it acts as glue between controller and view.

Controller<------> $Scope <------> View

Scopes are hierarchical in nature and follow the DOM structure of your AngularJS app. AngularJS has two scope objects: $rootScope and $scope.

19. Can you define multiple restrict options on a directive?
Answer: You can also specify multiple restrict options to support more than one methods of directive invocation as an element or an attribute. Make sure all are specified in the restrict keyword as:

restrict: 'EA'

20. What is restrict option in directive?
Answer: The restrict option in angular directive, is used to specify how a directive will be invoked in your angular app i.e. as an attribute, class, element or comment.
There are four valid options for restrict:

'A' (Attribute)-<span my-directive></span>
'C' (Class)-<span class="my-directive:expression;"></span>
'E' (Element)-<my-directive></my-directive>
'M' (Comment)-<!-- directive: my-directive expression -->



Share on Google Plus

About blackcat

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

1 comments:

  1. Angularjs Descriptive Questions For Exam (Part-1) - Idb-Bisew Exam Questions And Answer Bank >>>>> Download Now

    >>>>> Download Full

    Angularjs Descriptive Questions For Exam (Part-1) - Idb-Bisew Exam Questions And Answer Bank >>>>> Download LINK

    >>>>> Download Now

    Angularjs Descriptive Questions For Exam (Part-1) - Idb-Bisew Exam Questions And Answer Bank >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete