我處於這種情況,我想將內聯樣式應用於基於我在控制器中定義的標誌的DOM元素。其原因是我無法更改視圖中使用的現有CSS,也無法擴展它。如何在Angular的ng-class中使用內聯樣式?
這就是說,這裏是我當前的視圖代碼:需要時
<label class="control-label" ng-class="{'margin-left:100px' : is_modal}">Hello</label>
is_modal僅僅是我切換到真正的標誌/控制器錯誤。
上面的代碼不工作,我也試着:
<label class="control-label" ng-class="{'style=margin-left:100px' : is_modal}">Hello</label>
但也不起作用。任何人都知道這是否可能?定義內聯樣式?
另一種選擇是NG-風格,但我似乎無法控制我的標誌is_modal綁定到NG-風格,因爲它不允許索要條件爲NG-類做...
感謝 亞歷
很好的答案!這是我真正需要的,謝謝! – AlejandroVK