@angular/common
Implements fundamental Angular framework functionality, including directives and pipes, location services used in routing, HTTP services, localization support, and so on.
The CommonModule
exports are re-exported by BrowserModule
, which is included automatically in the root AppModule
when you create a new app with the CLI new
command.
入口点
主要
@angular/common | Implements fundamental Angular framework functionality, including directives and pipes, location services used in routing, HTTP services, localization support, and so on. |
次要
@angular/common/http | Implements an HTTP client API for Angular apps that relies on the |
@angular/common/http/testing | Supplies a testing module for the Angular HTTP subsystem. |
@angular/common/testing | Supplies infrastructure for testing functionality supplied by |
@angular/common/upgrade | Provides tools for upgrading from the |
主入口点的导出
模块
CommonModule | 导出所有基本的 Angular 指令和管道,例如 Exports all the basic Angular directives and pipes, such as |
类
HashLocationStrategy | A |
Location | 一个服务,应用可以用它来与浏览器的 URL 互动。 A service that applications can use to interact with a browser's URL. |
LocationStrategy | Enables the |
NgForOfContext | |
NgIfContext | |
NgLocaleLocalization | Returns the plural case based on the locale |
NgLocalization | |
PathLocationStrategy | A |
PlatformLocation | This class should not be used directly by an application developer. Instead, use |
ViewportScroller | Defines a scroll position manager. Implemented by |
函数
formatCurrency | Formats a number as currency using locale rules. |
formatDate | 基于区域规则格式化日期。 Formats a date according to locale rules. |
formatNumber | Formats a number as text, with group sizing, separator, and other parameters based on the locale. |
formatPercent | Formats a number as a percentage according to locale rules. |
getCurrencySymbol | Retrieves the currency symbol for a given currency code. |
getLocaleCurrencyCode | Retrieves the default currency code for the given locale. |
getLocaleCurrencyName | Retrieves the name of the currency for the main country corresponding to a given locale. For example, 'US Dollar' for |
getLocaleCurrencySymbol | Retrieves the symbol used to represent the currency for the main country corresponding to a given locale. For example, '$' for |
getLocaleDateFormat | Retrieves a localized date-value formating string. |
getLocaleDateTimeFormat | Retrieves a localized date-time formatting string. |
getLocaleDayNames | Retrieves days of the week for the given locale, using the Gregorian calendar. |
getLocaleDayPeriods | Retrieves day period strings for the given locale. |
getLocaleDirection | Retrieves the writing direction of a specified locale |
getLocaleEraNames | Retrieves Gregorian-calendar eras for the given locale. |
getLocaleExtraDayPeriodRules | Retrieves locale-specific rules used to determine which day period to use when more than one period is defined for a locale. |
getLocaleExtraDayPeriods | Retrieves locale-specific day periods, which indicate roughly how a day is broken up in different languages. For example, for |
getLocaleFirstDayOfWeek | Retrieves the first day of the week for the given locale. |
getLocaleId | Retrieves the locale ID from the currently loaded locale. The loaded locale could be, for example, a global one rather than a regional one. |
getLocaleMonthNames | Retrieves months of the year for the given locale, using the Gregorian calendar. |
getLocaleNumberFormat | Retrieves a number format for a given locale. |
getLocaleNumberSymbol | Retrieves a localized number symbol that can be used to replace placeholders in number formats. |
getLocalePluralCase | Retrieves the plural function used by ICU expressions to determine the plural case to use for a given locale. |
getLocaleTimeFormat | Retrieves a localized time-value formatting string. |
getLocaleWeekEndRange | Range of week days that are considered the week-end for the given locale. |
getNumberOfCurrencyDigits | Reports the number of decimal digits for a given currency. The value depends upon the presence of cents in that particular currency. |
isPlatformBrowser | Returns whether a platform id represents a browser platform. |
isPlatformServer | Returns whether a platform id represents a server platform. |
isPlatformWorkerApp | Returns whether a platform id represents a web worker app platform. |
isPlatformWorkerUi | Returns whether a platform id represents a web worker UI platform. |
registerLocaleData | Register global data to be used internally by Angular. See the "I18n guide" to know how to import additional locale data. |
结构
FormStyle | Context-dependant translation forms for strings. Typically the standalone version is for the nominative form of the word, and the format version is used for the genitive case. |
FormatWidth | String widths available for date-time formats. The specific character widths are locale-specific. Examples are given for |
KeyValue | A key value pair. Usually used to represent the key value pairs from a Map or Object. |
LocationChangeEvent | A serializable version of the event from |
LocationChangeListener | |
NumberFormatStyle | Format styles that can be used to represent numbers. |
NumberSymbol | Symbols that can be used to replace placeholders in number patterns. Examples are based on |
Plural | Plurality cases used for translating plurals to different languages. |
PopStateEvent | |
TranslationWidth | String widths available for translations. The specific character widths are locale-specific. Examples are given for the word "Sunday" in English. |
WeekDay | The value for each day of the week, based on the |
指令
NgClass | 从 HTML 元素上添加和移除 CSS 类。 Adds and removes CSS classes on an HTML element. |
NgComponentOutlet | Instantiates a single |
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 | 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 |
NgPlural | Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization. |
NgPluralCase | Creates a view that will be added/removed from the parent |
NgStyle | 一个属性指令,用于更新容器元素的样式。可以通过指定用冒号分隔的键值对来设置一个或多个样式属性。其键是样式名称,带有可选的 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 |
NgSwitch | A structural directive that adds or removes templates (displaying or hiding views) when the next match expression matches the switch expression. |
NgSwitchCase | Provides a switch case expression to match against an enclosing |
NgSwitchDefault | Creates a view that is rendered when no |
NgTemplateOutlet | 根据一个提前备好的 Inserts an embedded view from a prepared |
管道
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 | 把数字转换成字符串, 根据本地化规则进行格式化,这些规则会决定分组大小和分组分隔符、小数点字符以及其它与本地化环境有关的配置项。 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. |
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 | 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 | 从一个 Creates a new |
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. |
类型
APP_BASE_HREF | A predefined DI token for the base href to be used with the |
DOCUMENT | A DI Token representing the main rendering context. In a browser this is the DOM Document. |
LOCATION_INITIALIZED | Indicates when a location is initialized. |
Time | Represents a time value with hours and minutes. |