Emberjs如何绑定一个id [英] Emberjs how to bind-attr an id

查看:235
本文介绍了Emberjs如何绑定一个id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用ember属性通过调用它的动态id来切换div的可见性,但是即使我可以通过调用类来做类似的操作,对于id也不能这样做。

I want to use ember properties to toggle the visibility of a div by calling it's dynamic id, however even though I can do something similar by calling classes, I cannot do the same for id's.

例如: {{bind-attr class =:class1 controller.controllerProperty:class2}} 工作正常。我可以从控制器中的一个动作切换 controllerProperty

For example: {{bind-attr class=":class1 controller.controllerProperty:class2"}} works fine. I can toggle the controllerProperty from an action in my controller.

你会认为同样的概念适用于id 。然而, {{bind-attr id =:staticId controllerProperty:id {{dynamicIdNumber}}}} 使id消失在一起!

You would think the same concept would apply to id's. However {{bind-attr id=":staticId controllerProperty:id{{dynamicIdNumber}}"}} makes the id's disappear all together!

为什么会发生这种情况,正是这样做的正确方法是什么?我想尽可能避免解决方案。

Why is this happening and what is the correct method to be doing this sort of this? I would like to avoid work-around solutions as much as possible.

推荐答案

绑定到类是Ember中的一个特例,如所描述的在 here
将其他属性绑定到属性被描述此处

Binding to classes is a special case in Ember as described in here Binding the other attributes to properties is described here

这篇关于Emberjs如何绑定一个id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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