如何动态显示Durandal路线的标签? [英] How to dynamically display tabs for routes in Durandal?

查看:100
本文介绍了如何动态显示Durandal路线的标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个分为两个部分的问题.我对durandal和淘汰赛非常陌生.

This is a two part question. Am very new to durandal and knockout.

使用Durandal 2.0.1的HTML入门工具包示例.

Using the HTML Starter Kit example for Durandal 2.0.1.

我使用自己的vm为客户/:id添加一条路线,并使用nav = false查看

I add a route for customers/:id with my own vm and view with nav = false

 { route: 'customer/:id', moduleId: 'viewmodels/customer/customer', nav: false }

由于nav为false,因此在调用buildNavigationModel()时不会使用它.因此,shell.html不会显示其选项卡条目.到目前为止一切顺利.

Because nav is false, it doesn't get used when buildNavigationModel() is called. So the shell.html doesn't show a tab entry for it. So far so good.

  1. 当我导航到c:\ temp \ index.html#customer/123时,我可以看到该页面,但是它没有包含在页面顶部的选项卡中.当我查看shell.html时,它使用数据绑定来获取要在这些选项卡中显示的路由.那它不应该显示我刚移到的这条新路线吗?如果将路线nav设置为true,是否足以刷新shell显示?还是我第一次无法理解ko?

  1. When I navigate to c:\temp\index.html#customer/123 I can see the page, but it doesn't get included in the tabs at the top of the page. When I look at shell.html it uses data-bind to get the routes to display in those tabs. So shouldn't it display this new route I just moved to? If I set the routes, nav to true, would that be enough to refresh the shell display? Or am I failing at my first attempt to understand ko?

所以我有一条用于customer/:id的路线.如果我转到index#customer/123,则希望看到上面第1部分中的新标签.如果导航到index#customer/234,我也想看到一个新的标签.然后,用户应该能够在两个选项卡之间移动.这行得通吗,或者真的只记录了customer/:id路线,而我只会看到一个选项卡按钮吗?

So I have a route for customer/:id. If I go to index#customer/123 I want to see a new tab as of part 1 above. If I navigate to index#customer/234, I want to see a new tab for that as well. The user should then be able to move between the two tabs. Can this work, or is it really only recording the customer/:id route and I will only ever see one tab button?

推荐答案

路由器导航模型无法满足您的需求.查看 Durandal 2.0路由参数化的路由(相同的路由,不同的参数),以查看如何构建自己的导航模型的示例.

The router navigation model won't do what you're looking for. Check out Durandal 2.0 routing parameterized routes (same route different parameter) to see an example how to build your own navigation model instead.

这篇关于如何动态显示Durandal路线的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆