2015-04-24 64 views
-2

Here is my code如何使用NG-風格,同時從JSON歌廳風格

這是我的代碼ng-style="background: {{x.background}}"

什麼使ng-style="background: #f4f4f4"

我期待style="background: #f4f4f4"

+0

始終在StackOverflow中發佈相關代碼。人們通常不關心你是否與其他網站「鏈接」。請查看[如何使用Markdown或HTML格式化我的帖子](http://stackoverflow.com/help/formatting)以獲取有關在SO上格式化代碼的更多信息。 – Sufian

回答

0

變化這個

ng-style="background: {{x.background}}" 

ng-attr-style="background: {{x.background}}" 
1

試試這個:

ng-style="{ background: x.background}" 

這更加嚴密類似json的。實際上你可以有一個json對象並直接使用它。