×


js/nodejs/angularjs/ts interview questions

1  What is data binding in angularjs

Data binding in AngularJS is the synchronization between the model and the view.                                     

2  What are the key features of angularjs

  1.    Modules.
  2.    Directives.
  3.    Expressions.
  4.    Controller.
  5.    Scope.
  6.    Data Binding.
  7.    Validations.
  8.    Filters.
  9.    Services.
  10.  Routing.
  11.  Dependency Injection.
  12.  Testing.

3  What are directives

AngularJS extends HTML attributes with directives

4  What are controllers

Controllers are functions which provide data and logic to the HTML page we are going to visualize the data.

5  What do you mean by compile and link in angularjs

To have a complete understanding of angularjs understanding the angular is lifecycle is necessary .Angularjs lifecycle        has three phases.
Bootstrap phase-
The bootstrap phase is the phase in which the library is loaded,module is created based on your ng-app and any                dependencies to your module is loaded
Compilation phase-
The  compilation phase is the phase which include two steps Traversing the  DOM and collecting all the directives and        then linking the directives to the appropriate JavaScript functionality in the AngularJS built-in library or custom directive      code. The directives are combined with a scope to produce the dynamic page
Binding phase-In this the changes in scope are reflected in the DOM

6   What is scope-

Scope is an object that refers to the application model. It is an execution context for expressions. Scopes are arranged in hierarchical structure which mimic the DOM structure of the application. Scopes can watch expressions and propagate events.

7 What is angularjs digest cycle

The digest cycle in angularjs
Compilation phase-
The  compilation phase is the phase which include two steps Traversing the  DOM and collecting all the directives and       then linking the directives to the appropriate JavaScript functionality in the AngularJS built-in library or custom directive       code. The directives are combined with a scope to produce the dynamic page
binding phase-In this the changes in scope are reflected in the DOM.

In AngularJS,there are watchers for every scope variable that we declare.It keeps a watch list with the variable and the data.Digest cycle can be considered as a loop, during which AngularJS checks if there are any changes to all the variables watched by all the $scope.$watch helps to listen for $scope changes.

 

$apply enables to integrate changes with the digest cycle

8 How to implement internationalization in AngularJS?

AngularJS supports inbuilt internationalization for three types of filters currency, date and numbers.

9 What are directives in AngularJS

Directives are one of the most powerful components of AngularJS, helping you extend basic HTML elements/attributes and create reusable and testable code.AngularJS provides support to create custom directives for following type of elements.

Element directives − Directive activates when a matching element is encountered.

Attribute − Directive activates when a matching attribute is encountered.

CSS − Directive activates when a matching css style is encountered.

Comment − Directive activates when a matching comment is encountered.

factory method is used to define a factory which can later be used to create services as and when required whereas service method is used to create a service whose purpose is to do some defined task.

AngularJS provides $https: control which works as a service to make ajax call to read data from the server.

12 

Using AngularJS, we can embed HTML pages within a HTML page using ng-include directive.

13 Can we use nested controllers in AngularJS

Yes we can  defined nested controllers.If we define nested controllers then child controller will inherit the scope of its parent controller.

14 Routing in AngularJS

The ngRoute module helps your application to become a Single Page Application.

Then in your controller inject $routeParams:

15 How to use UI-Router

16 What is the difference between angular-route and angular-ui-router

ui-router is a 3rd-party module and is very powerful. It supports everything the normal ngRoute can do as well as many extra functions.

Here are some common reason ui-router is chosen over ngRoute:

ui-router allows for nested views and multiple named views. This is very useful with larger app where you may have pages that inherit from other sections.
ui-router allows for you to have strong-type linking between states based on state names. Change the url in one place will update every link to that state when you build your links with ui-sref. Very useful for larger projects where URLs might change.
There is also the concept of the decorator which could be used to allow your routes to be dynamically created based on the URL that is trying to be accessed. This could mean that you will not need to specify all of your routes before hand.
states allow you to map and access different information about different states and you can easily pass information between states via $stateParams.
You can easily determine if you are in a state or parent of a state to adjust UI element (highlighting the navigation of the current state) within your templates via $state provided by ui-router which you can expose via setting it in $rootScope on run.
In essence, ui-router is

17 How do you share data between controllers?

1 Parent child controllers

2 Using shared services

3 Using data in $rootScope

18 Whant are Array map functions in Javascript

The map() method is used to apply a function on every element in an array. A new array is then returned.

 

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *