【发布时间】:2015-12-02 22:20:23
【问题描述】:
我正在使用 Ionic 框架为移动设备创建单页应用程序。我的个人资料页面有一个基于选项卡的结构。在“主页”视图中,我有一个链接“编辑配置文件”,一旦单击它应该通过 ProfileManagementController.js 导航到 editprofile.html。当我单击它时,没有任何反应,控制台中也没有显示错误。只有地址栏中的 url 被更新。
这里是 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);
}
这是主页选项卡视图 (tab-home.html) 的 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>
这是我第一次登陆 tab-home.html 并单击不起作用的按钮后的 URL:
之前: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>
【问题讨论】:
-
将其更改为相对路径是否有效?即
ng-click="goToEditProfile('^.editProfile')" -
@potatopeelings 已经尝试过了,但没有