2015-11-05 55 views
0

我想在AngularJS中顯示帶有時間戳和圖例的銫球。但是我只看到時間戳,如果我註釋掉和移動什麼NG-應用沒有被註釋掉,它會顯示其他div的,但是我不能讓所有三個在同一添顯示一切然而空白:多個ng-app沒有顯示在頁面上

<div class="timeStamp" ng-app="myApp"> 
    <div ng-controller='TimeCtrl'> 
     <p>{{ clock | date:'MM-dd-yyyy HH:mm:ss'}}</p> 
    </div> 
</div> 
<div class="cesium" ng-app="ngCesium" ng-controller="appCtrl as appCtrl"> 
    <div cesium-directive="" id="cesium" class="cesiumContainer"></div> 
</div> 
<div ng-app="" class="categoryBox" data-ng-init="planes=['Commercial Planes','Private Planes']"> 
    Legend 
    <li data-ng-repeat="x in planes" ng-style="{ background: x == 'Commercial Planes' ? 'red' : 'blue' }"> 
     {{x}} 
    </li> 

</div> 

回答

0

你可以使用這樣的:

<!DOCTYPE html> 
<html> 
<head> 
    <script src="angular.js"></script> 
    <script src="angular.ng-modules.js"></script> 
    <script> 
    var moduleA = angular.module("MyModuleA", []); 
    moduleA.controller("MyControllerA", function($scope) { 
    $scope.name = "Bob A"; 
    }); 

    var moduleB = angular.module("MyModuleB", []); 
    moduleB.controller("MyControllerB", function($scope) { 
    $scope.name = "Steve B"; 
    }); 
    </script> 
</head> 
<body> 
    <div ng-modules="MyModuleA, MyModuleB"> 
    <h1>Module A, B</h1> 
    <div ng-controller="MyControllerA"> 
     {{name}} 
    </div> 
    <div ng-controller="MyControllerB"> 
     {{name}} 
    </div> 
    </div> 

    <div ng-module="MyModuleB"> 
    <h1>Just Module B</h1> 
    <div ng-controller="MyControllerB"> 
     {{name}} 
    </div> 
    </div> 
</body> 
</html> 

請參考以下鏈接它會幫助你:

AngularJS Multiple ng-app within a page