私は2つの異なるAngularJsモジュールを持っています:widgetContainerとウィジェット。AngularJSのネストされたモジュール
ウィジェットは、独立したアプリケーションとして表示することも、ウィジェットコンテナに含めることもできます。 widgetContainerには0-Nウィジェットが含まれています。
私はwidgetContainerにウィジェットモジュールをブートストラップを試みる場合、角度スロー次のエラー:
: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
<div id="parentApp">
<div ng-controller="MainParentCtrl">
Hello {{name}} !
<div id="childApp">
<div ng-controller="MainChildCtrl">
Hello {{childName}} !
</div>
</div>
</div>
EDITでこのエラーを再現しています
依存性注入を使用してprを解決する効率的に取り組む。
これで、ディレクティブからウィジェットをロードする必要があります。
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));
}
};
}]);
divが作成されていますが、childAppモジュールが内部にロードされていません。 私が期待される結果を達成するために、私のplunker
はそう同じ要素。リファレンス:https://docs.angularjs.org/error/ng/btstrpd –