2015-11-28 39 views
0

我正在使用Ionic Framework爲移動設備創建單頁應用程序。我有一個基於標籤的配置文件頁面結構。在「Home」視圖中,我點擊一個鏈接「Edit Profile」,它應該通過ProfileManagementController.js導航到editprofile.html。當我點擊它時,沒有任何反應,也沒有錯誤顯示在控制檯中。只有地址欄中的網址纔會更新。

這裏是app.js途徑編碼:

.state('editProfile', { 
    url: '/editProfile', 
    views: { 
     'tab-editprofile': { 
     templateUrl: 'templates/profile/editprofile.html', 
     controller: 'ProfileManagementController' 
     } 
    } 
    }) 

這在ProfileManagementController.js剪斷有關此功能:

$scope.goToEditProfile = function(path) 
{ 
    $state.go(path); 
} 

這是首頁標籤查看HTML形式(tab-home.html),其中按鈕存在導航到編輯配置文件:

<div> 
      Name: {{tempUserObject.name}} <br/> 
      Friends: {{tempUserObject.totalFriends}}<br/> 
      Mobile: {{tempUserObject.mobile}}<br/> 
      Username: {{tempUserObject.username}} <br/> 
      <br/> 
      <button ng-click="goToEditProfile('editProfile')" class="button">Edit Profile</button> 

     </div> 

這是在原來的網址,當我在製表home.html的,點擊按鈕後第一個土地不起作用:

前:http://127.0.0.1:49259/index.html#/tab/home 後:http://127.0.0.1:49259/index.html#/editProfile

請幫助指導我找出這個鏈接出了什麼問題。我以前在其他地方使用過$ state.go,並且運行良好。

更新:editprofile.html添加。

<ion-view hide-nav-bar="false" title="Edit Profile"> 
    <ion-content padding="'true'" class="has-header"> 
     <div class="spacer" style="width: 300px; height: 87px;"></div> 
     <div class="button-bar"></div> 
     <h2>Edit Profile</h2> 
    </ion-content> 
</ion-view> 
+0

不將其改爲相對路徑工作?即'ng-click =「goToEditProfile('^。editProfile')」' – potatopeelings

+0

@potatopeelings已經嘗試過,並且它不會 –

回答

1

使用此代替狀態更改。

$location.path('/editProfile'); 

不要忘記在控制器功能中注入$ location。

+0

Yup現在已經這樣做了,並且注入了位置但沒有工作。如前所述,只有URL更改。 $狀態不是問題,所以$ location不是解決方案。其他功能在相同的app.js工作狀態 –

+0

顯示您的代碼editProfile html – Robus

+0

更新完成.... –

0

你的app.js中定義了一個名爲'path'的狀態嗎? 如果不創建一個名爲「路徑」用模板和控制器就像「editprofile」狀態

0

所以我固定在app.js修改路線如下上述問題狀態:

.state('editprofile', { 
    url: '/editprofile', 
    templateUrl: 'templates/profile/editprofile.html', 
    controller: 'ProfileManagementController' 
    }) 
相關問題