Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS - inline css style rendering

Is it possible / and how / to write inline css style using angular variables?

<div style="background: transparent url({{eventInfo.eventHeaderImg}}) top center no-repeat;"></div> 

This is my output

"NetworkError: 404 Not Found - http://test/eventInfo.eventHeaderImg"

So I see it didn't render this value.

I know it's possible to change this in controller, but is it doable with my approach?

like image 340
Djomla Avatar asked Apr 25 '14 09:04

Djomla


1 Answers

You should use ngStyle:

an example: http://plnkr.co/edit/qT8skZzTwXjrh3Ye5mr9?p=preview

<div ng-style="{ background: 'transparent url({{ eventInfo.eventHeaderImg }}) top center no-repeat' }"></div> 
like image 139
Ilan Frumer Avatar answered Sep 26 '22 05:09

Ilan Frumer