你就必須做到這一點使用ng-include
。你的主視圖應該
<body ng-app>
<div id='topNav' ng-include='templateUrl' ng-controller='topNavController'></div>
<div id='left' ng-include='templateUrl' ng-controller='leftNavController'></div>
<div ng-view>
</body>
的templateUrl
可以從服務器或預裝到使用<script>
標籤的客戶端。
JavaScript看起來像。
function topNavController($scope, $route, $location) {
//Check using $route or $location if login view is loaded
// if yes $scope.templateUrl='loginTopNavTemplateUrl'
//else $scope.templateUrl='mainNavTemplateUrl'
}
爲ng-include
,$route
和$location
檢查文檔,看看這些元素如何如何工作的。
我覺得這個職位回答你的問題:http://stackoverflow.com/questions/11541695/angular-js-redirecting-to-a-certain-基於路由上條件 – user3393575