Which element has the rootscope?

102 Views Asked by At

In Angular JS, for below code body is where the rootscope is present. Basically the element which has "ng-app" directive, has the rootscope.

<html>
 <head></head>
 <body ng-app> <!--The RootScope -->
 </body>
</html>

Question - When there is no ng-app directive and we are manually bootstrapping our angular app using "angular.bootstrap", where is the rootscope, or rather which element becomes the owner of rootscope?

1

There are 1 best solutions below

0
On

Whatever element you pass at angular bootstrap initialization, becomes the root of your application.

Refer the angular bootstrap documentation:https://docs.angularjs.org/api/ng/function/angular.bootstrap

Usage

angular.bootstrap(element, [modules], [config]);

//element - DOM element which is the root of angular application.

Example:

angular.bootstrap(document, ['demo']);