【发布时间】:2015-01-14 06:52:39
【问题描述】:
我在 Durandal 中有以下导航设置:
layout.js
...
that.activate = function () {
router.map([
{ route: '', title: abp.localization.localize('HomePage', 'MyProject'), moduleId: 'viewmodels/home', nav: true, menuName: 'Home' },
{ route: 'editpage/:id', title: abp.localization.localize('EditPage', 'MyProject'), moduleId: 'viewmodels/editpage', hash: '#/editpage/id' }
]).buildNavigationModel();
pages.js
...
that.editPage = function (page) {
that.router.navigate('editpage/' + page.id());
};
pages.cshtml
<ul class="list-group" data-bind="foreach: pages">
<div class="list-group-item">
<span class="page-name" data-bind="text: name"></span>
<div class="text-right">
<!--<button type="button" class="btn btn-info btn-sm" data-bind="click: $parent.editPage">-->
<button type="button" class="btn btn-info btn-sm" data-bind="attr: {href: '#/editpage/' + id()}">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> @L("EditPage")
</button>
</div>
</div>
</ul>
当我点击编辑页面按钮时,我想导航到“EditPage/:id”页面。但是只有点击绑定有效:
<button type="button" class="btn btn-info btn-sm" data-bind="click: $parent.editPage">
attr href 绑定没有:
<button type="button" class="btn btn-info btn-sm" data-bind="attr: {href: '#/editpage/' + id()}">
我尝试了几种配置方式,但似乎都没有帮助。我猜这只是路由配置或哈希中的不正确语法。想不通。
任何帮助将不胜感激!
【问题讨论】:
标签: durandal