CommonModule
导出所有基本的 Angular 指令和管道,例如 NgIf
、NgForOf
、DecimalPipe
等。 它会由 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.
提供商
提供商 |
---|
|
指令
名称 | 说明 |
---|---|
| 从 HTML 元素上添加和移除 CSS 类。 Adds and removes CSS classes on an HTML element. |
| Instantiates a single |
| 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. |
| 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 |
| Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization. |
| Creates a view that will be added/removed from the parent |
| 一个属性指令,用于更新容器元素的样式。可以通过指定用冒号分隔的键值对来设置一个或多个样式属性。其键是样式名称,带有可选的 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 |
| A structural directive that adds or removes templates (displaying or hiding views) when the next match expression matches the switch expression. |
| Provides a switch case expression to match against an enclosing |
| Creates a view that is rendered when no |
| 根据一个提前备好的 Inserts an embedded view from a prepared |
管道
名称 | 说明 |
---|---|
| 从一个异步回执中解出一个值。 Unwraps a value from an asynchronous primitive. |
| 把数字转换成金额字符串, 根据本地化规则进行格式化,这些规则会决定分组大小和分组分隔符、小数点字符以及其它与本地化环境有关的配置项。 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. |
| 根据区域设置规则格式化日期值。 Formats a date value according to locale rules. |
| 把数字转换成字符串, 根据本地化规则进行格式化,这些规则会决定分组大小和分组分隔符、小数点字符以及其它与本地化环境有关的配置项。 Transforms a number into a string, formatted according to locale rules that determine group sizing and separator, decimal-point character, and other locale-specific configurations. |
| Maps a value to a string that pluralizes the value according to locale rules. |
| Generic selector that displays the string that matches the current value. |
| 把一个值转换成 JSON 字符串格式。在调试时很有用。 Converts a value into its JSON-format representation. Useful for debugging. |
| Transforms Object or Map into an array of key value pairs. |
| 把文本转换成全小写形式。 Transforms text to all lower case. |
| 把数字转换成百分比字符串, 根据本地化规则进行格式化,这些规则会决定分组大小和分组分隔符、小数点字符以及其它与本地化环境有关的配置项。 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. |
| 从一个 Creates a new |
| 把文本转换成标题形式。 把每个单词的第一个字母转成大写形式,并把单词的其余部分转成小写形式。 单词之间用任意空白字符进行分隔,比如空格、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. |
| 把文本转换成全大写形式。 Transforms text to all upper case. |