2014-10-17 41 views
0

我是AngularJs的開始者,而且在我的angularapp中,我想通過URL從左側菜單中選擇選項來傳遞URL。但我沒有辦法訪問這些。AngularJS + SwitchCase通過點擊列表項來呈現不同的URL

<ion-content> 
    <ul class="list"> 
    <a href="#/ShowItems" class="item" menu-close>Yahoo</a> 
    <a href="#/ShowItems" class="item" menu-close>Google</a> 
    </ul> 
</ion-content> 

ScriptPage模板

<script id="templates/show_items.html" type="text/ng-template"> 
    <ion-view title="Yahoo"> 
    <ion-content> 
     <form class="list" ng-show="showForm"> 
     <div class="item item-divider"> 
      URL Info 
     </div> 
     <label class="item item-input"> 
      <input type="text" placeholder="CurrentURL" ng-model=""> 
     </label> 
     <div class="padding"> 
      <button class="button button-block" ng-click="submit()">Checkin</button> 
     </div> 
     </form> 
    </ion-content> 
    </ion-view> 
</script> 

我試圖在角加開關的情況下(按照URL)的選擇特定的頁面將呈現。

非常感謝。

UPDATE

添加幾個鏈接以何種方式我想顯示的頁面。我希望每個鏈接的頁面標題在佈局內單擊並呈現該頁面。

CodePen Link

回答

0

您可以使用

HTML

<ion-content> 
    <ul class="list"> 
    <a href="#/ShowItems" class="item" menu-close ng-click="item('yahoo')">Yahoo</a> 
    <a href="#/ShowItems" class="item" menu-close ng-click="item('google')">Google</a> 
    </ul> 
</ion-content> 

控制器

$scope.item = function(site){ 
     if(site == 'yahoo'){ 
      $scope.currentURL = "www.yahoo.com"; 
     }else{ 
      $scope.currentURL = "www.google.com"; 
     } 
} 

並在輸入型的地方{{CURRENTURL}}只要你想。

+0

但我不想爲每次點擊製作單獨的頁面。在單個頁面中,我想渲染點擊的URL值。 – Rubyist 2014-10-17 09:27:01

+0

你想渲染被點擊的URL值的位置? – 2014-10-17 09:39:28

+0

您可以看到具有一個輸入框的templates/show_items.html。在那我將把一個開關條件,並根據我將改變內容。 – Rubyist 2014-10-17 10:12:12

相關問題