2015-05-14 34 views
0

已經創建了一個使用兩個單獨區域顯示數據的應用程序。一個在另一個之上(因爲這似乎是一個很酷的想法:))如何避免使用角度狀態重新加載

我的問題是,兩者都是由狀態控制的,我無法弄清楚如何使它底層狀態不更新時頂層是。不過,我希望底層始終在那裏。

這是怎麼了我已成立了國家

.config(function ($stateProvider, $urlRouterProvider) { 
     $urlRouterProvider.otherwise(''); //Setting the default to the padz 

     $stateProvider 
      .state('index', { 
       url: '', 
       views: { 
        "musicview": { 
         templateUrl: 'partials/music', 
         controller: 'MusicController' 
        }, 
        "controlview": { 
         templateUrl: 'controlview/welcome', 
         controller: 'ControllerCV' 
        } 
       } 

      }) 
      .state('about', { 
       url: 'about', 
       views: { 
        "musicview": { 
         templateUrl: 'partials/music', 
         controller: 'MusicController' 
        }, 
        "controlview": { 
         templateUrl: 'controlview/welcome', 
         cotroller: 'ContrillerCV' 
        } 
       } 

      }) 
      .state('config', { 
       url: 'config', 
       views: { 
        "musicview": { 
         templateUrl: 'partials/music', 
         controller: 'MusicController' 
        }, 
        "controlview": { 
         templateUrl: 'controlview/config', 
         cotroller: 'ControllerCV' 
        } 
       } 
      }) 
      .state('contact', { 
       url: 'contact', 
       views: { 
        "musicview": { 
         templateUrl: 'partials/music', 
         controller: 'MusicController' 
        }, 
        "controlview": { 
         templateUrl: 'controlview/contact', 
         cotroller: 'ControllerCV' 
        } 
       } 
      }) 
      .state('forum', { 
       url: 'forum', 
       views: { 
        "musicview": { 
         templateUrl: 'partials/music', 
         controller: 'MusicController' 
        }, 
        "controlview": { 
         templateUrl: 'controlview/forum', 
         cotroller: 'ControllerCV' 
        } 
       } 
      }) 

這是UI的意見

<div id="musiccontainer"> 
    <div ui-view="musicview"></div> 
</div><!-- End of container--> 

<div id="controllayer"> 
    <% include controlview/controls/defaults.ejs %> 
     <div id="controlwindow"> 
      <div ui-view="controlview"> 
      </div> 
    </div> 
    <% include controlview/controls/playlog.ejs %> 
</div> 

回答

0

由於這兩種觀點都有國將smultaneously切換。 也許,如果你想他們中的一個將永遠存在,你需要從視圖列表中刪除,只是有這樣的結構:

<!-- this one will be always managed by one controller : myStaticDataController--> 
<div id="musiccontainer"> 
    <div ng-controller="myStaticDataController"> 
    </div> 
</div> 

<!-- this one will be changing accoriding to the states--> 
<div id="controllayer"> 
    <% include controlview/controls/defaults.ejs %> 
     <div id="controlwindow"> 
      <div ui-view="controlview"> 
      </div> 
    </div> 
    <% include controlview/controls/playlog.ejs %> 
</div> 
+0

到目前爲止,我還沒有開始做,許多與背層,但我我打算這樣做,只是我希望同一個背景頁面在大部分時間顯示相同的數據(並避免重新加載),然後有時根據前面的狀態進行更改。 – vrghost