@angular/common

package

Implements basic Angular directives and pipes, such as NgIf, NgForOf, DecimalPipe, 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.

Entry points

Primary

@angular/common

Implements basic Angular directives and pipes, such as NgIf, NgForOf, DecimalPipe, and so on.

Secondary

@angular/common/http

Implements an HTTP client API for Angular apps that relies on the XMLHttpRequest interface exposed by browsers.

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

Primary entry point exports

NgModules

CommonModule

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.

DeprecatedI18NPipesModule

Deprecated: from v5

A module that contains the deprecated i18n pipes.

Classes

HashLocationStrategy

A LocationStrategy used to configure the Location service to represent its state in the hash fragment of the browser's URL.

Location

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

LocationStrategy

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

NgForOfContext
NgIfContext
NgLocaleLocalization

Returns the plural case based on the locale

NgLocalization
PathLocationStrategy

A LocationStrategy used to configure the Location service to represent its state in the path of the browser's URL.

PlatformLocation

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

ViewportScroller

Manages the scroll position.

Functions

formatCurrency

Formats a number as currency using locale rules.

formatDate

Formats a date according to 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.

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

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.

getLocaleDateFormat

Date format that depends on the locale.

getLocaleDateTimeFormat

Date-time format that depends on the locale.

getLocaleDayNames

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

getLocaleDayPeriods

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

getLocaleEraNames

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

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 getLocaleExtraDayPeriodRules to determine which period to use. You should fallback to AM/PM when there are no day periods available.

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.

getLocaleId

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

getLocaleMonthNames

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

getLocaleNumberFormat

Number format that depends on the locale.

getLocaleNumberSymbol

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

getLocalePluralCase

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

getLocaleTimeFormat

Time format that depends on the locale.

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.

getNumberOfCurrencyDigits

Returns the number of decimal digits for the given currency. Its 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.

Structures

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.

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).

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
NumberFormatStyle

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

NumberSymbol

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

Plural
PopStateEvent
TranslationWidth

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

WeekDay

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

Directives

NgClass

Adds and removes CSS classes on an HTML element.

NgComponentOutlet

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

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.

NgIf

Conditionally includes a template based on the value of an 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 NgPlural when the given expression matches the plural expression according to CLDR rules.

NgStyle

Update an HTML element styles.

NgSwitch

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

NgSwitchCase

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

NgSwitchDefault

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

NgTemplateOutlet

Inserts an embedded view from a prepared TemplateRef.

Pipes

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.

DeprecatedCurrencyPipe

Formats a number as currency using locale rules.

DeprecatedDatePipe

Formats a date according to locale rules.

DeprecatedDecimalPipe

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

DeprecatedPercentPipe

Formats a number as percentage 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.

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

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.

UpperCasePipe

Transforms text to all upper case.

Types

APP_BASE_HREF

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

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

A representation of the time with hours and minutes

© 2010–2019 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v6.angular.io/api/common