JavaScript Nested modules in AngularJS angularjs nested modules,angularjs nested modules example

I Have 2 differents AngularJs modules : a widgetContainer and a widget.

A widget can be displayed as an independant application or be included into a widgetContainer. A widgetContainer contains 0-N widgets.

If i try to boostrap the widget module into the widgetContainer, angular throw the following error :

Error: [ng:btstrpd] App already bootstrapped with this element '<div id="childApp">' http://errors.angularjs.org/1.5.8/ng/btstrpd?p0=%26lt%3Bdiv%20id%3D%22childApp%22%26gt%3B

I have reproduce this error in this plunk

<div id="parentApp">
<div ng-controller="MainParentCtrl">
  Hello {{name}} !
  <div id="childApp">
    <div ng-controller="MainChildCtrl">
      Hello {{childName}} !
    </div>
  </div>
</div>

EDIT :

Using Dependency injection solve the problem efficiently.

Now, I need to load the widget from a directive.

parentApp.directive('widget', [function() {
  return {
    restrict: 'E',
    link: function($scope, $element, $attr) {

      var div = document.createElement('div');
      div.setAttribute("ng-controller", "MainChildCtrl");
      div.innerHTML = 'Hello {{childName}} !';
      $element.append(angular.element(div));

    }
  };
}]);

The div is created but the childApp module is not loaded inside. I have updated my plunker

Answer:1

To achieve expected result, use below

angular.element(document).ready(function() {
  angular.bootstrap(document.getElementById('parentApp'), ['parentApp','childApp']);

});

http://plnkr.co/edit/4oGw5ROo80OCtURYMVa3?p=preview

Syntax for manual bootstrap is as below irrespective of usage of controllers on elements

angular.bootstrap(element, [modules]);
Answer:2

So I am building a Chrome DevTools extension that inspects binary traffic on particular website. Requests on site are made with responseType = "blob". Now when I get request with chrome.devtools....

So I am building a Chrome DevTools extension that inspects binary traffic on particular website. Requests on site are made with responseType = "blob". Now when I get request with chrome.devtools....

  1. javascript reading binary files
  2. javascript reading binary data
  3. js reading binary file

The solution to this problem might be very trivial but its got me banging my head on walls! Bootstrap's js files are not loading on my web page for some reason. I simplified the page to the bare ...

The solution to this problem might be very trivial but its got me banging my head on walls! Bootstrap's js files are not loading on my web page for some reason. I simplified the page to the bare ...

  1. bootstrap loading bar
  2. bootstrap loading mask
  3. bootstrap loading placeholder
  4. bootstrap loading buttons
  5. bootstrap loading spinner modal
  6. bootstrap loading overlay example
  7. bootstrap loading spinner on button click
  8. bootstrap loading button on click
  9. bootstrap loading spinner overlay example
  10. bootstrap loading spinner modal example
  11. bootstrap loading dots
  12. bootstrap loading progress bar
  13. bootstrap loading spinner not showing
  14. bootstrap loading bar circle
  15. bootstrap loading component
  16. bootstrap loading spinner css
  17. bootstrap loading spinner in center
  18. bootstrap loading example
  19. bootstrap loading spinner react
  20. bootstrap loading full screen

I'm working on a responsive menu for a quite complex website. The horizontal menu collapses to a vertical one for smaller screens and I've used javascript to toggle the sub-menu items open/closed when ...

I'm working on a responsive menu for a quite complex website. The horizontal menu collapses to a vertical one for smaller screens and I've used javascript to toggle the sub-menu items open/closed when ...

  1. javascript toggle menu button
  2. javascript toggle menu script
  3. javascript toggle menu
  4. javascript toggle menu example
  5. javascript toggle menu mobile
  6. javascript toggle menu code
  7. javascript toggle menu stack overflow
  8. toggle menu javascript
  9. javascript toggle dropdown menu
  10. vanilla javascript toggle menu
  11. javascript for toggle menu bar
  12. pure javascript toggle menu
  13. javascript multiple toggle menu
  14. javascript toggle responsive menu
  15. javascript dropdown menu toggle on click
  16. javascript hamburger menu toggle
  17. javascript side menu toggle
  18. bootstrap javascript menu toggle

How to open the modal after a ajax call on success i need to trigger the modal window automatically <a class="main_blue_button" href="#complete_application_modal" id="applicationBtn">SIGN UP<...

How to open the modal after a ajax call on success i need to trigger the modal window automatically <a class="main_blue_button" href="#complete_application_modal" id="applicationBtn">SIGN UP<...