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

CommonModule

匯出所有基本的 Angular 指令和管道,例如 NgIfNgForOfDecimalPipe 等。 它會由 BrowserModule 進行二次匯出,當你使用 CLI 的 new 命令建立新應用時,BrowserModule 會自動包含在根模組 AppModule 中。

Exports all the basic Angular directives and pipes, such as NgIf, NgForOf, DecimalPipe, and so on. Re-exported by BrowserModule, which is included automatically in the root AppModule when you create a new app with the CLI new command.

檢視"說明"...

      
      class CommonModule {
}
    

說明

  • providers 選項配置了 NgModule 的注入器,來為其成員提供本地化依賴。

    The providers options configure the NgModule's injector to provide localization dependencies to members.

  • exports 選項讓這裡宣告的指令和管道可以被匯入到其它 NgModule 中。

    The exports options make the declared directives and pipes available for import by other NgModules.

提供商

提供商
      
      { provide: NgLocalization, useClass: NgLocaleLocalization }
    

指令

名稱說明
      
      NgClass
    

從 HTML 元素上新增和移除 CSS 類別。

Adds and removes CSS classes on an HTML element.

      
      NgComponentOutlet
    

實例化單個 Component型別,並將其宿主檢視插入當前檢視。NgComponentOutlet 為動態元件建立提供了一種宣告式方法。

Instantiates a single Componenttype and inserts its Host View into current View. NgComponentOutlet provides a declarative approach for dynamic component creation.

      
      NgForOf
    

一種結構型指令,為集合中的每個條目渲染一個範本。如果指令放置在一個元素上,該元素就會成為複製後的範本的父級。

A structural directive that renders a template for each item in a collection. The directive is placed on an element, which becomes the parent of the cloned templates.

      
      NgIf
    

本結構型指令用於根據表示式的值(強轉為 boolean)是否為真值,來有條件的包含某個範本。當表示式計算為 true 時,Angular 會渲染 then 子句中提供的範本,當為 false 或 null 時則渲染可選的 else 子句中的範本。else 子句的預設範本是空白範本。

A structural directive that conditionally includes a template based on the value of an expression coerced to Boolean. When the expression evaluates to true, Angular renders the template provided in a then clause, and when false or null, Angular renders the template provided in an optional else clause. The default template for the else clause is blank.

      
      NgPlural
    

根據數字值新增/刪除 DOM 子樹。為支援複數詞量身訂製。

Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization.

      
      NgPluralCase
    

建立一個檢視,當給定表示式根據 CLDR 規則與複數表示式匹配時,將在父檢視 NgPlural中新增/刪除該檢視。

Creates a view that will be added/removed from the parent NgPluralwhen the given expression matches the plural expression according to CLDR rules.

      
      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.

      
      NgSwitch
    

容器上的 [ngSwitch] 指令指定要匹配的表示式。匹配的表示式由容器內檢視上的 ngSwitchCase 指令提供。

The [ngSwitch] directive on a container specifies an expression to match against. The expressions to match are provided by ngSwitchCase directives on views within the container.

      
      NgSwitchCase
    

提供一個 switch case 表示式來匹配一個封閉的 ngSwitch 表示式。當表示式匹配時,將渲染給定的 NgSwitchCase 範本。如果多個匹配表示式與開關表示式值相匹配,則會全部顯示。

Provides a switch case expression to match against an enclosing ngSwitch expression. When the expressions match, the given NgSwitchCase template is rendered. If multiple match expressions match the switch expression value, all of them are displayed.

      
      NgSwitchDefault
    

建立一個當沒有任何 NgSwitchCase 表示式能匹配 NgSwitch 表達時要渲染的檢視。該語句應該是 NgSwitch 的最後一種情況。

Creates a view that is rendered when no NgSwitchCase expressions match the NgSwitch expression. This statement should be the final case in an NgSwitch.

      
      NgTemplateOutlet
    

根據一個提前備好的 TemplateRef 插入一個內嵌檢視。

Inserts an embedded view from a prepared TemplateRef.

管道

名稱說明
      
      AsyncPipe
    

從一個非同步回執中解出一個值。

Unwraps a value from an asynchronous primitive.

      
      CurrencyPipe
    

Transforms a number to a currency string, formatted according to locale rules that determine group sizing and separator, decimal-point character, and other locale-specific configurations.

      
      DatePipe
    

根據區域設定規則格式化日期值。

Formats a date value according to locale rules.

      
      DecimalPipe
    

Formats a value according to digit options and locale rules. Locale determines group sizing and separator, decimal point character, and other locale-specific configurations.

      
      I18nPluralPipe
    

將值對映到根據語言環境規則對該值進行復數化的字串。

Maps a value to a string that pluralizes the value according to locale rules.

      
      I18nSelectPipe
    

通用選擇器,用於顯示與當前值匹配的字串。

Generic selector that displays the string that matches the current value.

      
      JsonPipe
    

把一個值轉換成 JSON 字串格式。在除錯時很有用。

Converts a value into its JSON-format representation. Useful for debugging.

      
      KeyValuePipe
    

將 Object 或 Map 轉換為鍵值對陣列。

Transforms Object or Map into an array of key value pairs.

      
      LowerCasePipe
    

把文字轉換成全小寫形式。

Transforms text to all lower case.

      
      PercentPipe
    

Transforms a number to a percentage string, formatted according to locale rules that determine group sizing and separator, decimal-point character, and other locale-specific configurations.

      
      SlicePipe
    

從一個 ArrayString 中建立其元素一個新子集(slice)。

Creates a new Array or String containing a subset (slice) of the elements.

      
      TitleCasePipe
    

把文字轉換成標題形式。 把每個單詞的第一個字母轉成大寫形式,並把單詞的其餘部分轉成小寫形式。 單詞之間用任意空白字元進行分隔,比如空格、Tab 或換行符。

Transforms text to title case. Capitalizes the first letter of each word and transforms the rest of the word to lower case. Words are delimited by any whitespace character, such as a space, tab, or line-feed character.

      
      UpperCasePipe
    

把文字轉換成全大寫形式。

Transforms text to all upper case.