Top AngularJS Questions and Answers

    1 Votes

31) List out the components which can be used in AngularJS modules?

Below are the list of components –
  • Controller
  • Filter
  • Provider
  • Factory
  • Routes
  • Service
  • Directive
32) Which is the core module in AngularJS?

“ng” is the core module in AngularJS and this module will be loaded by default when angular application has started.

33) How looping has been done in AngularJS?
Looping can be achieved like below in AngularJS –
<li data-ng-repeat="mytestname in names">
{{ mytestname }}
34) Explain factory methods in AngularJS?

Factory methods are used for creating a directive. It can be invoked only once that is when compiler matches the directive.

35) Can we create a custom directive in AngularJS?

Yes we can create custom directive.

36) How to load select box during page initialization using AngularJS?

Below is the sample code to initialize the select box using AngularJS –

<div ng-controller = “mycontroller” ng-init = “loaddataforselectBox()”>

37) How AngularJS will automatically be initialized?

AngularJS will be initialized during “DOMContentLoaded” event or during the angular.js file download to browser. Now AngularJS looks for directive – “ng-app”, which is a root compilation for AngularJS.

38) What is the difference between Rootscope and Scope in AngularJS?

  • Rootscope – Rootscope is the top most scope and one application can have an only one rootscope and will be shared among all the components.
  • Scope - Scope will act like a glue between view and controller and scopes are arranged in hierarchical structure.

39) Give an example for Rootscope in AngularJS?

Rootscope acts like a global variable and below is the sample code for the same –

<body ng-app="mytestApp"> 
<div ng-controller="MyFirstController" style="border:2px solid blue; padding:5px"> 
Hi {{mymsg}}!
<br /> 
Hi {{myname}}! (rootScope) 
<br /> 
<div ng-controller="MySecondController" style="border:2px solid green; padding:5px"> 
Hello {{mymsg}}! 
<br /> 
Hi {{name}}! (rootScope) 

<script src="/lib/angular.js"></script> 
var app = angular.module('mytestApp', []);

app.controller('MyFirstController', function ($scope, $rootScope) { 
$scope.msg = 'Good Morning'; 
$ = 'Test My scope'; 

app.controller('MySecondController', function ($scope, $rootScope) { 
$scope.msg = 'Good Night'; 
$scope.CheckName = $; 

40) Do I need to use Jquery in AngularJS?

No. No need to use Jquery in AngularJS.

Page 3 of 5

Popular Videos


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