2015-06-20 90 views
0

我有一個奇怪的問題。當ng-view顯示「觀看遊戲視圖」,移動邊欄直接,它的嵌套指令工作正常時,我創建了一個移動邊欄指令(一個sibiling html元素指向另一個ng-directive元素) 。但是當我進入「添加用戶視圖」時,移動邊欄指令停止工作。我在調試時沒有發現腳本錯誤。在ng視圖中更改視圖時,自定義指令不起作用,angularjs

開始菜單的Html

<div id="mainContainer" ng-controller="StartCtrl"> 
    <div id="menuContainer"> 
    <mobile-side-bar menu-id="{{menuIds}}" id="menu" class="hideElement"> 
     <div ng-include src="viewActions"></div> 
    </mobile-side-bar> 
    </div> 

    <div ng-view class="view-animate"></div> 

</div> 

<script type="text/ng-template" id="addUsers.html"> 
    <advertise-game player-search-spinner-on="playerSearchSpinnerOn"> </advertise-game> 
    <invite-friend></invite-friend> 
    <player-search></player-search> 
</script> 

mainMenuRoute

var mainMenuapp = angular.module('monopolyMenuModule', ['ngRoute', 'ngAnimate']); 
mainMenuapp.config(['$routeProvider', '$locationProvider', 
    function ($routeProvider, $locationProvider) { 
     $routeProvider 
     .when('/', 
      angularAMD.route({ 
       templateUrl: 'Js/MonopolyMenu/StartMenu.html', 
       controller: 'StartCtrl', 
       controllerUrl: 'MonopolyMenu/monopoly-menu' 
      }) 
     ) 
.when('/WatchGame', angularAMD.route({ 
     templateUrl: 'Js/MonopolyMenu/WatchGameMenu.html', 
     controller: 'WatchGameCtrl', 
     controllerUrl: 'MonopolyMenu/monopoly-menu' 
    }) 
    ) 
    .when('/RegisterUsers', angularAMD.route({ 
     templateUrl: 'Js/MonopolyMenu/AddUsers.html', 
     controller: 'AddUsersCtrl', 
     controllerUrl: 'MonopolyMenu/monopoly-menu' 
     //controllerAs: 'addUsers' 
    }) 
    ).otherwise({ redirecTo: "/" }); 

添加用戶的Html 添加用戶

<div spinner spinneron="playerSearchSpinnerOn" close-spinner-call-back="endUserSearch()"> 

</div> 

<div id="xs-userDetails" class="visible-xs list-group"> 

</div> 
<div class="actionButtonsBar"> 
    <div class="actionButtonsPadding"> 
     <a href="javascript:history.back()">Back</a> 
    </div> 
</div> 

添加用戶按Ctrl

monopolyMenuModule.controller('AddUsersCtrl', ['$scope', 'GameGroupDetails', 'viewNamesEnum', function ($scope, GameGroupDetails, viewNamesEnum) { 

    // add code to call notifyUsers object.. watch pluralsight "connecting our server to client" and "how signalr works" 
    $scope.playerSearchSpinnerOn = false; 

    $scope.$parent.menuViewName = viewNamesEnum.AddUsersView; 

    $scope.$parent.viewActions = "addUsers.html"; 

    $scope.$parent.menuIds = "1"; 

    $scope.endUserSearch = function() { 
     // add code to remove gameDetails from list. 
    } 

}]) 

回答

0

正如你所使用的腳本模板與模板的名字被存儲爲addUsers.html URL中$templateCacheid="addUsers.html"。你需要在你的/RegisterUsers路線定義改變templateUrladdUsers.html

代碼

.when('/RegisterUsers', angularAMD.route({ 
    templateUrl: 'addUsers.html', //<-- change here 
    controller: 'AddUsersCtrl', 
    controllerUrl: 'MonopolyMenu/monopoly-menu' 
    //controllerAs: 'addUsers' 
}) 
+0

@rayabu它幫助你的? –

相關問題