javascript - How to pass to a component an attribute with variable and static parts in EmberJs? -
i'm trying pass link-to component style attribute. it's not default attributebinding, had reopen linkcomponent class , add 'style' attribute there.
ember.linkcomponent.reopen({ attributebindings: ['style'] }); doing that, can set following:
{{#link-to element.link element.param style="background: red;"}}text link{{/link-to}} it render , see eye-burning link red background.
what i'm trying achieve apply image url background-image property on style attr.
{{#link-to element.link element.param style="background-image: url(element.background);"}}text link{{/link-to}} but i'm getting variable name inside attribute.
i tried with:
- element.background
- ${element.background}
- {{element.background}}
- treat sum of string , variable parts "url("+element.background+")" breaks code compilation
i know seems computed property, , passing url , creating whole value inside class, or maybe passing value formatted on first place style=element.background trick, it's link-to helper i'd prefer keep listening style attribute , model holding url values.
any or idea broadly welcomed.
you can use concat helper,
style=(concat 'background-image: url(' element.background ');') reference : http://emberjs.com/api/classes/ember.templates.helpers.html#method_concat
Comments
Post a Comment