Top AngularJS Questions and Answers

    1 Votes

16) Explain directives – “ng-init”, “ng-model” and “ng-app” in AngularJS?

  • “ng-init” – This directive is used for initializing the angular app data.
  • “ng-model” – This directive is used to bind the html elements like – select, input, text area etc.
  • “ng-app” - This directive initializes the angular app.
17) Which is the core module of AngularJS?

“ng” is the core module of AngularJS and when angular app is started this module will be loaded by default.

18) How dependencies are loaded in AngularJS?

Dependencies are loaded using blocks – configuration and run.

19) List out the differences between config and run methods in AngularJS?

  • Config Block – Constants and providers can be injected into config blocks and this block can be created using config method.
  • Run Block – Run block will be executed after config block. Run block is used to inject constants and instances and this block can be created using run method.

Eg :

angular.module('myTestModule', []).
config(function (injectables) {
// config block
}).
run(function (injectables) {
// run block
});

20) List out types of directives in AngularJS?

Below are the list of directives in AngularJS –

  • Attribute directives
  • Comment directives
  • Element directives
  • CSS class directives

21) Explain injector in AngularJS?

Injector is service locator and it’s used for retrieving object instances as defined by instantiate types, provider and load modules.

22) List out styling forms used with ngModel for css classes?

Below are the list of styling forms used for css classes with ngModel

  • ng-dirty
  • ng- valid
  • ng-pristine
  • ng- invalid

23) Explain prefixes – “$” and “$$” in AngularJS?

Both prefixes are used to prevent the collisions in the code.

  • “$” – Public objects uses this prefix.
  • “$$” – Private objects uses this prefix.

24) Explain filters in AngularJS?

Filters are mainly used to format the data before displaying it in the screen to the user. This can be used in services, controllers, directives and templates.

Eg: Syntax of the filter

 {{ expression | filter}}

<script type="text/javascript">
{ { 25 | currency } } //returns $25.00
</script>

25) List out few filters supported by AngularJS?

Below are few filters provided by AngularJS –

  • Date
  • Currency
  • OrderBy
  • Lowercase
  • Uppercase
  • Number etc.

26) How to define multiple restrict options on a directive in AngularJS?

We can specify multiple restrict options for supporting more than one method. All methods should specify restrict keyword like below –

restrict: 'TA'

27) Explain services in AngularJS?

Services are singleton functions or objects which are used to carry out specific tasks. It will hold the business logic, which are called as controllers, filters, directives and so on.

28) What are data bindings in AngularJS?

Data binding is the process of synchronizing of data between view and model.

29) What are the types of data binding in AngularJS?

Below are the list of types of data bindings in Angular JS

  • Data binding in angular templates
  • Data mining in classical template systems

30) Why to use “$http” in AngularJS?

  • "$http" is used as an AngularJS service to read data from remote server.
  • “$http.get(url)” method is used for this purpose by specifying the url as a parameter.
Page 2 of 5

Popular Videos

communication

How to improve your Interview, Salary Negotiation, Communication & Presentation Skills.

Got a tip or Question?
Let us know

Related Articles

HTML/HTML5 Interview Questions and Answers
JQuery Interview Questions and Answers
Javascript Interview Questions and Answers
Top 60+ Node.JS Interview Questions and answers
Top 70 CSS Interview Questions and Answers
React JS Interview Questions and Answers