【发布时间】:2014-12-27 20:52:44
【问题描述】:
您好,我在模板文件夹中有两个单独的模板,分别名为“home.html”和“home.singleLink.html”。
home.html 看起来像这样
<ion-list>
<ion-item ng-repeat="link in links">
<a class="button button-clear" ui-sref="home({singleLink: link.name})">{{link.name}}</a>
</ion-item>
<ion-list>
我想显示“home.singleLink.html”模板并在用户单击 ui-sref 中的链接时消失“home.html”模板。我在“家”之后传递了一个变量
这是我的 app.config 的样子
$stateProvider
.state('home', {
url: '/home',
templateUrl: 'templates/home.html',
controller: 'linksController'
})
.state('home.singleLink', {
url: '/:singleLink',
templateUrl: 'templates/home.singleLink.html',
controller: 'linksController'
})
据我所知,当用户点击链接时,ui-sref 会生成一个 href。但在我的情况下,当我检查链接时,我可以看到一个额外的 href="#/home" 以及当我点击链接时没有改变的 ui-sref。
提前致谢。
【问题讨论】:
-
看起来你的 state home 没有 singleLink 参数,你的意思是使用 singleLink 状态吗?
-
哦,对不起,这是一个错误。我尝试了很多愚蠢的不同方法,但没有奏效。我现在正在删除“/home”:)
-
在您的 html 模板中,尝试 ui-sref="home.singleLink({singleLink: link.name})"
标签: angularjs angular-ui-router ionic-framework