0

I want to know the list of modules already bootstrapped.

I have use ng-app with main modules but there are small modules which are inside it . I have used $controller service inside main controller to access controller of sub module .

So is there any way to know that whether modules is bootstrapped or not?

Sample structure

<div ng-app="main">
 <div ng-controller="mctrl">
 </div>
 <div ng-app="sub">
  <div ng-controller="subCtrl">
  </div>
 </div>
</div>

Controller

var app = angular.module('main',[]);
app.controller('mctrl',function($scope,$controller){
      var sub = $scope.$new();
      //check module is bootstrapped or not
       $controller('subCtrl',{
         $scope:scope
       });
      sub.check();//getting instance of controller 
});
Shubham Nigam
  • 3,844
  • 19
  • 32

1 Answers1

0

You can have only one time ng-app in your application but when you define the app like var main = angular.module("main", [dependency module1,]) you will add the modules you need on application bootstrap.

You can read here more about AngularJS modules.

As per Angular doc:

Important things to notice:

The Module API The reference to myApp module in . This is what bootstraps the app using your module. The empty array in angular.module('myApp', []). This array is the list of modules myApp depends on.

Please let me know if you understood this.

Radu
  • 1,047
  • 12
  • 34
  • Hi,@radu you are telling about dependency of module.where i want to know module is bootstrapped or not.. – Shubham Nigam Feb 17 '16 at 05:55
  • second app won't bootstrap you can have only on app. into an html page. If you want to see data from the second module you will need to add it as dependency. So the answer is no the second module as you wrote will not be loaded. You can have 2 or more ng-controller directives but only one ng-app. – Radu Feb 17 '16 at 06:35