This is the archived documentation for Angular v6. Please visit angular.io to see documentation for the current version of Angular.

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.

See more...

class CommonModule { }
      
      class CommonModule {
}
    

Description

  • The providers options configure the NgModule's injector to provide localization dependencies to members.
  • The exports options make the declared directives and pipes available for import by other NgModules.

Providers

Provider
{ provide: NgLocalization, useClass: NgLocaleLocalization }
      
      { provide: NgLocalization, useClass: NgLocaleLocalization }
    

Directives

NameDescription
NgClass
      
      NgClass
    

Adds and removes CSS classes on an HTML element.

NgComponentOutlet
      
      NgComponentOutlet
    

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

NgForOf
      
      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
      
      NgIf
    

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

NgPlural
      
      NgPlural
    

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

NgPluralCase
      
      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
      
      NgStyle
    

Update an HTML element styles.

NgSwitch
      
      NgSwitch
    

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

NgSwitchCase
      
      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
      
      NgSwitchDefault
    

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

NgTemplateOutlet
      
      NgTemplateOutlet
    

Inserts an embedded view from a prepared TemplateRef.

Pipes

NameDescription
AsyncPipe
      
      AsyncPipe
    

Unwraps a value from an asynchronous primitive.

CurrencyPipe
      
      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
      
      DatePipe
    

Formats a date value according to locale rules.

DecimalPipe
      
      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
      
      DeprecatedCurrencyPipe
    

Formats a number as currency using locale rules.

DeprecatedDatePipe
      
      DeprecatedDatePipe
    

Formats a date according to locale rules.

DeprecatedDecimalPipe
      
      DeprecatedDecimalPipe
    

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

DeprecatedPercentPipe
      
      DeprecatedPercentPipe
    

Formats a number as percentage according to locale rules.

I18nPluralPipe
      
      I18nPluralPipe
    

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

I18nSelectPipe
      
      I18nSelectPipe
    

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

JsonPipe
      
      JsonPipe
    

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

KeyValuePipe
      
      KeyValuePipe
    

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

LowerCasePipe
      
      LowerCasePipe
    

Transforms text to all lower case.

PercentPipe
      
      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
      
      SlicePipe
    

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

TitleCasePipe
      
      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
      
      UpperCasePipe
    

Transforms text to all upper case.