Explain $rootScope in AngularJS.

Every AngularJS application contains a $rootScope, which is the top-most scope created on the DOM element. An application can contain only one $rootScope, which will be shared among all its components. Every other scope is considered as its child scope. It can watch expressions and propagate events. By using the root scope, one can set … Read more

Do you think that parent controller can access the methods of child controller or vice versa?

No, the parent controller cannot access the methods of child controller, but the child controller can access the methods of the parent controller. In AngularJS, controllers in the same scope hierarchy can communicate with each other, but direct access to methods of one controller from another is not recommended. Controllers in AngularJS are meant to … Read more

What is the syntax for creating a new date object?

The syntax for creating new date object is given below: $scope.newDate=new Date(); In AngularJS, you can use the Date object to work with dates. To create a new date object, you can use the following syntax: javascript var myDate = new Date(); This will create a new Date object representing the current date and time. … Read more

Is it possible to have two ng-app directives for a single Angular application?

No, there can’t be more than one ng-app directive for a single AngularJS application. The ng-app directive helps AngularJS application to make sure that it is the root element. In our HTML document, we can have only one ng-app directive. If there is more than one ng-app directive, then whichever appears first will be used. … Read more

Describe the AngularJS boot process.

When a page is loaded into the browser, several things happen: HTML document file gets loaded, and evaluated by the browser. AngularJS JavaScript file gets loaded, and the angular global object is created. Next, JavaScript file which is responsible for registering the controller functions is executed. AngularJS scans through the HTML to find AngularJS apps … Read more