Link-给助手动态分配class
Link-to helper to dynamically assign class
我明白了:
When the rendered link matches the current route, and the same object instance is passed into the helper, then the link is given class="active".
http://emberjs.com/guides/templates/links/
当"active"匹配当前路由时,是否可以通过link-to helper将class名称传递给模板?
更具体地说,我希望 link 生成的 <li>
标记-在当前路由与 [=38] 的路由匹配时帮助获取 class="open"
=]-帮助者。
谢谢
更新
jasonmit 的以下回答适用于需要传递参数的动态路由。由于我的路由是静态的,因此我不传递参数。此外,我需要为 <li>
分配 class 打开。因此,我嵌套了两个 link-to。第一个link-生成<li>
标签并在link-匹配路由时添加class="open"
。第二个link-生成一个<a>
标签就是HTML.
中的link
{{#link-to 'communications' tagName="li" activeClass="open"}}
{{#link-to 'communications'}}
<i class="icon-rocket"></i>
<span class="title">communication</span>
{{/link-to}}
{{/link-to}}
{{link-to 'home' 'home' activeClass='opened'}}
我明白了:
When the rendered link matches the current route, and the same object instance is passed into the helper, then the link is given class="active". http://emberjs.com/guides/templates/links/
当"active"匹配当前路由时,是否可以通过link-to helper将class名称传递给模板?
更具体地说,我希望 link 生成的 <li>
标记-在当前路由与 [=38] 的路由匹配时帮助获取 class="open"
=]-帮助者。
谢谢
更新
jasonmit 的以下回答适用于需要传递参数的动态路由。由于我的路由是静态的,因此我不传递参数。此外,我需要为 <li>
分配 class 打开。因此,我嵌套了两个 link-to。第一个link-生成<li>
标签并在link-匹配路由时添加class="open"
。第二个link-生成一个<a>
标签就是HTML.
{{#link-to 'communications' tagName="li" activeClass="open"}}
{{#link-to 'communications'}}
<i class="icon-rocket"></i>
<span class="title">communication</span>
{{/link-to}}
{{/link-to}}
{{link-to 'home' 'home' activeClass='opened'}}