Ember.js binding a css style in a template

后端 未结 4 1622
孤城傲影
孤城傲影 2021-02-02 12:15

This is solved since Ember 1.8 with the HTMLBars engine.

I would like to bind a css style in a template. What would be the solution ?

I tr

相关标签:
4条回答
  • 2021-02-02 12:33

    Add unbound:

    <div class="bar" style="width:{{unbound barWidth}}px"></div>
    
    0 讨论(0)
  • 2021-02-02 12:36

    In Ember 2.0:

    <div class="bar" style="width:{{barWidth}}px"></div>
    

    will just work.

    0 讨论(0)
  • 2021-02-02 12:39

    To simplify all that, I created a tiny handlebars helper for emberjs that allows you to bind any style properties. You can look at https://github.com/yderidde/bindstyle-ember-helper

    0 讨论(0)
  • 2021-02-02 12:48

    Set a string on your view that looks like "width: 100px" and then bind it to your div with the bind-attr helper like so: <div {{bind-attr style="divStyle"}}>Test</div>

    http://jsfiddle.net/tomwhatmore/rearT/1/

    0 讨论(0)
提交回复
热议问题