snipt

Ctrl+h for KB shortcuts

HTML

AngularJS: ng-style with variable

<div ng-style="{'background-image': 'url(' + book.cover + ')'}"></div>
https://snipt.net/embed/f361a1f79ab16a484bede2fa39b7dc22/
/raw/f361a1f79ab16a484bede2fa39b7dc22/
f361a1f79ab16a484bede2fa39b7dc22
html
HTML
1
2019-06-10T10:57:34
True
False
True
Jan 21, 2014 at 05:46 PM
/api/public/snipt/107609/
angularjs-ng-style-with-variable
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="p">&lt;</span><span class="nt">div</span> <span class="na">ng-style</span><span class="o">=</span><span class="s">&quot;{&#39;background-image&#39;: &#39;url(&#39; + book.cover + &#39;)&#39;}&quot;</span><span class="p">&gt;&lt;/</span><span class="nt">div</span><span class="p">&gt;</span> </span></pre></div> </td></tr></table>
angularjs, ng-style, variable