2017-05-27 7 views
0

ルーティングはどのように角度ui-routerと状態で動作するか理解しています。

私はionic(v1)、angular、およびesri jsapiをベースにしたアプリを持っています。私はイオンのサイドメニューと角度UIルータを使用しています。私のサイトをロードすると、地図ビューが表示されます。サイドメニューを使用して駅に移動し、駅の詳細を表示した後、マップボタンをクリックして地図上の場所をズームすると、$状態になります.go()をマップビューに追加すると、ビュー/コントローラが再び初期化されることがわかります。これを見るには、コンソールを見直して、マップビューの最初の読み込み後に再度「CREATE MAP」が表示されていることを確認します。

私はそうのようにセットアップ私の状態​​をしました:

 .state('app.map', { 
      url: '/map', 
      cache: true, 
      reload: false, 
      params: { 
       attributes: null 
      }, 
      views: { 
       'menuContent': { 
        templateUrl: 'templates/map.html', 
        controller: 'MapController' 
       } 
      } 
     }) 
     .state('app.detail', { 
      url: '/detail', 
      cache: false, 
      params: { 
       properties: null 
      }, 
      views: { 
       'menuContent': { 
        templateUrl: 'templates/detail.html', 
        controller: 'DetailController' 
       } 
      } 
     }) 

私はマップビューに詳細ビューからの移行時のマップビュー/コントローラの再インスタンス化を避けるためにしたいと思います。詳細ページのボタンをクリックすると、元のマップビューの状態に移行することが期待されますが、マップビューの別のインスタンスを作成しようとしているようです。マップのサイドメニューボタンをクリックすると、再初期化されず、元のマップビューが表示されます。ここ

サイト:

EV Charge Stations

答えて

0

あなたが同様にNG-HREFを使用している場合、それは正常に動作しているので、それはあなたに https://github.com/angular-ui/ui-router/issues/1758を助けることができるかもしれこれらの議論を経またhttps://github.com/angular-ui/ui-router/issues/64

をお試しくださいng-clickを使用する代わりに、ui-hrefを使用して、状態名を返す関数を呼び出すのではなく、このようなもの;

<ion-item ng-repeat="feature in features | filter: {attributes: {Property: search.input}} as filteredCount" 
class="item item-icon-left item-icon-right" 
ui-sref={{onListItemClick({&quot;Station_Id&quot;:487,&quot;Property&quot;:&quot;Neal Blaisdell Center Parking Structure&quot;,&quot;Street_Address&quot;:&quot;777 Ward Avenue&quot;,&quot;City&quot;:&quot;Honolulu&quot;,&quot;Zip_Code&quot;:96814,&quot;Island&quot;:&quot;Oahu&quot;,&quot;In_Use&quot;:&quot;No&quot;,&quot;Charger_Fee_Type&quot;:&quot;Free&quot;,&quot;Charger_Notes&quot;:&quot;Enter S. King Street/Victoria street. Follow blue signs to Charger.&quot;,&quot;Hours_of_Operation&quot;:&quot;6:00am-12:00am&quot;,&quot;Charger_Count&quot;:1,&quot;Charger_Port&quot;:1,&quot;Charger_Level&quot;:2,&quot;Charger_Fee&quot;:&quot;Free&quot;,&quot;Parking_Fee&quot;:&quot;Free for EV Drivers&quot;,&quot;Network&quot;:&quot;ChargePoint&quot;,&quot;Notes&quot;:&quot;Activate charger with ChargePoint Network card or call the number listed on the front of the charger for access. &quot;,&quot;Latitude&quot;:21.299434,&quot;Longitude&quot;:-157.850378,&quot;Location&quot;:&quot;(21.299434, -157.850378)&quot;,&quot;Other1&quot;:null,&quot;Other2&quot;:null,&quot;Other3&quot;:null,&quot;Other4&quot;:null,&quot;Other5&quot;:null,&quot;Other6&quot;:null,&quot;Other7&quot;:null,&quot;Other8&quot;:null,&quot;Other9&quot;:null,&quot;Other10&quot;:null,&quot;FID&quot;:3,&quot;CreationDate&quot;:1484871379520,&quot;Creator&quot;:&quot;dpascual_HEC&quot;,&quot;EditDate&quot;:1484871379520,&quot;Editor&quot;:&quot;dpascual_HEC&quot;,&quot;Hawaiian_Station&quot;:null,&quot;OwnedBy&quot;:null,&quot;ChargingStandards&quot;:null,&quot;Servicing&quot;:null,&quot;ServiceNotes&quot;:null}) }}> 

       </ion-item> 

Controller.js

$scope.onListItemClick = function (attributes) { 
      var data = { 
       properties: attributes 
      }; 
      return "app.detail({attributes:"+data+"})" ; 
     } 

私はこれがあなたの問題を解決したいと考えています。

関連する問題