填寫這份《一分鐘調查》,幫我們(開發組)做得更好!去填寫Home

NgStyle

一個屬性指令,用於更新容器元素的樣式。可以透過指定用冒號分隔的鍵值對來設定一個或多個樣式屬性。其鍵是樣式名稱,帶有可選的 <unit> 字尾(比如 'top.px','font-style.em');其值是待求值的表示式。如果求值結果不是 null,則把用指定單位表示的結果賦值給指定的樣式屬性;如果是 null,則刪除相應的樣式。

An attribute directive that updates styles for the containing HTML element. Sets one or more style properties, specified as colon-separated key-value pairs. The key is a style name, with an optional .<unit> suffix (such as 'top.px', 'font-style.em'). The value is an expression to be evaluated. The resulting non-null value, expressed in the given unit, is assigned to the given style property. If the result of evaluation is null, the corresponding style is removed.

Exported from

選擇器

屬性

屬性說明
@Input()
ngStyle: { [klass: string]: any; }
只寫

說明

將容器元素的字型設定為表示式的結果。

Set the font of the containing element to the result of an expression.

      
      <some-element [ngStyle]="{'font-style': styleExp}">...</some-element>
    

將容器元素的寬度設定為表示式返回的畫素值。

Set the width of the containing element to a pixel value returned by an expression.

      
      <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element>
    

使用返回鍵值對的表示式來設定樣式值的集合。

Set a collection of style values using an expression that returns key-value pairs.

      
      <some-element [ngStyle]="objExp">...</some-element>
    

方法

      
      ngDoCheck()
    
引數

沒有引數。