In an Ember.js Handlebars template, is there a way to have both static and dynamic class attributes?

后端 未结 4 1968
青春惊慌失措
青春惊慌失措 2021-02-13 19:34

Using the already-overused to-do app example, let\'s say I want an element with a \"todo\" class (static) and an \"is-done\" class (dynamic):



        
4条回答
  •  囚心锁ツ
    2021-02-13 20:31

    EDIT:

    We've fixed this in Ember!

    On a build from master, or after 0.9.6 is released, you can now do:


    Previous answer:

    You unfortunately can't have both static and dynamic class names when using bindAttr.

    I suggest using one or more computed properties on your view to output both static and dynamic class names.

    Supporting both static and dynamic class names would be very nice, but the way bindAttr currently works, it's not possible. bindAttr doesn't know anything about the element it's being attached to during template compilation.

提交回复
热议问题