@angular/common

入口点

主要

@angular/common

次要

@angular/common/http
@angular/common/http/testing
@angular/common/testing

导出列表

NgLocaleLocalization

Returns the plural case based on the locale

NgLocalization
CommonModule

The module that includes all the basic Angular directives like NgIf, NgForOf, ...

该模块包含了所有基本的 Angular 指令,如 NgIfNgForOf等……

DeprecatedI18NPipesModule

A module that contains the deprecated i18n pipes.

该模块包含了已废弃的 i18n 管道。

NgForOfContext
NgIfContext
ViewportScroller

Manages the scroll position.

PlatformLocation

This class should not be used directly by an application developer. Instead, use Location.

LocationStrategy

LocationStrategy is responsible for representing and reading route state from the browser's URL. Angular provides two strategies: HashLocationStrategyand PathLocationStrategy.

HashLocationStrategy

A LocationStrategyused to configure the Locationservice to represent its state in the hash fragment of the browser's URL.

PathLocationStrategy

A LocationStrategyused to configure the Locationservice to represent its state in the path of the browser's URL.

Location

A service that applications can use to interact with a browser's URL.

一个服务,应用可以用它来与浏览器的 URL 互动。

函数

formatDate

Formats a date according to locale rules.

基于区域规则格式化日期。

formatCurrency

Formats a number as currency using locale rules.

formatNumber

Formats a number as text. Group sizing and separator and other locale-specific configurations are based on the locale.

formatPercent

Formats a number as a percentage according to locale rules.

registerLocaleData

Register global data to be used internally by Angular. See the "I18n guide" to know how to import additional locale data.

getNumberOfCurrencyDigits

Returns the number of decimal digits for the given currency. Its value depends upon the presence of cents in that particular currency.

getCurrencySymbol

Returns the currency symbol for a given currency code, or the code if no symbol available (e.g.: format narrow = $, format wide = US$, code = USD) If no locale is provided, it uses the locale "en" by default

getLocaleDayPeriods

Periods of the day (e.g. [AM, PM] for en-US).

getLocaleDayNames

Days of the week for the Gregorian calendar (e.g. [Sunday, Monday, ... Saturday] for en-US).

getLocaleMonthNames

Months of the year for the Gregorian calendar (e.g. [January, February, ...] for en-US).

getLocaleId

The locale id for the chosen locale (e.g en-GB).

getLocaleEraNames

Eras for the Gregorian calendar (e.g. AD/BC).

getLocaleWeekEndRange

Range of days in the week that represent the week-end for this locale, based on english days (Sunday = 0, Monday = 1, ...). For example in english the value would be [6,0] for Saturday to Sunday.

getLocaleFirstDayOfWeek

First day of the week for this locale, based on english days (Sunday = 0, Monday = 1, ...). For example in french the value would be 1 because the first day of the week is Monday.

getLocaleDateFormat

Date format that depends on the locale.

getLocaleDateTimeFormat

Date-time format that depends on the locale.

getLocaleExtraDayPeriodRules

Rules used to determine which day period to use (See dayPeriods below). The rules can either be an array or a single value. If it's an array, consider it as "from" and "to". If it's a single value then it means that the period is only valid at this exact value. There is always the same number of rules as the number of day periods, which means that the first rule is applied to the first day period and so on. You should fallback to AM/PM when there are no rules available.

getLocaleExtraDayPeriods

Day Periods indicate roughly how the day is broken up in different languages (e.g. morning, noon, afternoon, midnight, ...). You should use the function getLocaleExtraDayPeriodRulesto determine which period to use. You should fallback to AM/PM when there are no day periods available.

getLocalePluralCase

The locale plural function used by ICU expressions to determine the plural case to use. See NgPluralfor more information.

getLocaleTimeFormat

Time format that depends on the locale.

getLocaleNumberSymbol

Number symbol that can be used to replace placeholders in number formats. See NumberSymbolfor more information.

getLocaleNumberFormat

Number format that depends on the locale.

getLocaleCurrencyName

The name of the currency for the main country using this locale (e.g. USD for the locale en-US). The name will be null if the main country cannot be determined.

getLocaleCurrencySymbol

The symbol used to represent the currency for the main country using this locale (e.g. $ for the locale en-US). The symbol will be null if the main country cannot be determined.

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.

结构

Plural
NumberFormatStyle

The different format styles that can be used to represent numbers. Used by the function getLocaleNumberFormat.

FormStyle

Some languages use two different forms of strings (standalone and format) depending on the context. Typically the standalone version is the nominative form of the word, and the format version is in the genitive. See the CLDR website for more information.

TranslationWidth

Multiple widths are available for translations: narrow (1 character), abbreviated (3 characters), wide (full length), and short (2 characters, only for days).

FormatWidth

Multiple widths are available for formats: short (minimal amount of data), medium (small amount of data), long (complete amount of data), full (complete amount of data and extra information).

NumberSymbol

Number symbol that can be used to replace placeholders in number patterns. The placeholders are based on english values:

WeekDay

The value for each day of the week, based on the en-US locale

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 onPopState or onHashChange

LocationChangeListener
PopStateEvent

指令

NgClass

Adds and removes CSS classes on an HTML element.

从 HTML 元素上添加和移除 CSS 类。

NgForOf

The NgForOf directive instantiates a template once per item from an iterable. The context for each instantiated template inherits from the outer context with the given loop variable set to the current item from the iterable.

NgForOf 指令会为可迭代对象中的每一个条目实例化一个模板。实例化时的上下文环境来自其外部环境,它以当前正在迭代的条目作为循环变量。

NgIf

Conditionally includes a template based on the value of an expression.

根据 expression 表达式的值,有条件的包含某个模板。

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 NgPluralwhen the given expression matches the plural expression according to CLDR rules.

NgStyle

Update an HTML element styles.

修改 HTML 元素的样式。

NgSwitch

Adds / removes DOM sub-trees when the nest match expressions matches the switch expression.

根据内嵌的 match(匹配)表达式(match_express_*)与 switch(多路开关)表达式(switch_expression)的匹配结果,添加 / 删除 DOM 子树。

NgSwitchCase

Creates a view that will be added/removed from the parent NgSwitchwhen the given expression evaluate to respectively the same/different value as the switch expression.

如果指定的表达式的计算结果和 switch 表达式相同,就会在父指令 NgSwitch中创建一个视图;如果不同,则移除。

NgSwitchDefault

Creates a view that is added to the parent NgSwitchwhen no case expressions match the switch expression.

当没有任何 case 表达式匹配 switch 表达式的结果时,就会在父指令 NgSwitch中创建一个视图。

NgTemplateOutlet

Inserts an embedded view from a prepared TemplateRef.

根据一个提前备好的 TemplateRef 插入一个内嵌视图。

NgComponentOutlet

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

管道

AsyncPipe

Unwraps a value from an asynchronous primitive.

从一个异步回执中解出一个值。

DatePipe

Formats a date value according to locale rules.

根据区域设置规则格式化日期值。

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

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

把一个值转换成 JSON 字符串格式。在调试时很有用。

LowerCasePipe

Transforms text to all lower case.

把文本转换成全小写形式。

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.

把数字转换成金额字符串, 根据本地化规则进行格式化,这些规则会决定分组大小和分组分隔符、小数点字符以及其它与本地化环境有关的配置项。

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.

把数字转换成字符串, 根据本地化规则进行格式化,这些规则会决定分组大小和分组分隔符、小数点字符以及其它与本地化环境有关的配置项。

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 Array or String containing a subset (slice) of the elements.

从一个 ArrayString 中创建其元素一个新子集(slice)。

UpperCasePipe

Transforms text to all upper case.

把文本转换成全大写形式。

TitleCasePipe

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.

把文本转换成标题形式。 把每个单词的第一个字母转成大写形式,并把单词的其余部分转成小写形式。 单词之间用任意空白字符进行分隔,比如空格、Tab 或换行符。

KeyValuePipe

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

DeprecatedDatePipe

Formats a date according to locale rules.

DeprecatedCurrencyPipe

Formats a number as currency using locale rules.

DeprecatedDecimalPipe
DeprecatedPercentPipe

Formats a number as percentage according to locale rules.

类型

Time

A representation of the time with hours and minutes

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.

APP_BASE_HREF

The APP_BASE_HREF token represents the base href to be used with the PathLocationStrategy.