Issue
My html is this:
<div data-ng-attr-style="background:url({{ backgroundImage}}) !important; background-size:cover;" ></div>
Now I can put the condition inside the double curly braces {{ only.
But it breaks if I put a condition.
I want to have a condition like this :
data-ng-attr-style="condition ? {background:url({{ backgroundImage}}) !important; background-size:cover;} : {display:none}"
How can I resolve this?
Solution
You will need to put your condition inside {{ }}:
data-ng-attr-style="{{ condition ? 'background:url(' + backgroundImage + ') !important; background-size:cover' : 'display: none' }}"
Or you put in several lines for better readability:
data-ng-attr-style="{{
condition
? 'background: url(' + backgroundImage + ') !important; background-size: cover;'
: 'display: none'
}}"
Answered By - dfsq
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.