我想将App3(Root应用程序)的值传递给其他子应用程序,但我无法在下面执行相同的操作。请帮助。
我想知道是否可以编写父ng-app并将父ng-app的变量用于其子ng-app?
<div id="3">
<div ng-controller="root">
{{ abc }}
<div id="1">
<div ng-controller="myCrtl">
<p>{{ flag+" "+abc}}</p>
</div>
</div>
<div id="2">
<div ng-controller="myCrtl1">
<p>{{ flag1+" "+flag}}</p>
</div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.4/angular.js">
</script>
<script>
var app1 = angular.module('MyApp1', []);
var app2 = angular.module('MyApp2', ['MyApp1']);
var app3 = angular.module('MyApp3', ['MyApp1', "MyApp2"]);
app3.controller('root', function($scope) {
$scope.abc = "abc";
});
app1.controller('myCrtl', function($scope) {
$scope.flag = "ctr1";
});
app2.controller('myCrtl1', function($scope) {
$scope.flag1 = "ctr2";
});
angular.element(document).ready(function() {
angular.bootstrap(document.getElementById('1'), ['MyApp1']);
angular.bootstrap(document.getElementById('2'), ['MyApp2']);
angular.bootstrap(document.getElementById('3'), ['MyApp3']);
})
</script>
&#13;