fix(common): add `@Injectable()` to common pipes (#29834)

PR Close #29834
This commit is contained in:
Olivier Combe 2019-04-11 15:39:29 +02:00 committed by Igor Minar
parent 5b32f55a3a
commit 387fbb8106
9 changed files with 22 additions and 9 deletions

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {ChangeDetectorRef, EventEmitter, OnDestroy, Pipe, PipeTransform, WrappedValue, ɵisObservable, ɵisPromise} from '@angular/core'; import {ChangeDetectorRef, EventEmitter, Injectable, OnDestroy, Pipe, PipeTransform, WrappedValue, ɵisObservable, ɵisPromise} from '@angular/core';
import {Observable, SubscriptionLike} from 'rxjs'; import {Observable, SubscriptionLike} from 'rxjs';
import {invalidPipeArgumentError} from './invalid_pipe_argument_error'; import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
@ -67,6 +67,7 @@ const _observableStrategy = new ObservableStrategy();
* *
* @publicApi * @publicApi
*/ */
@Injectable()
@Pipe({name: 'async', pure: false}) @Pipe({name: 'async', pure: false})
export class AsyncPipe implements OnDestroy, PipeTransform { export class AsyncPipe implements OnDestroy, PipeTransform {
private _latestValue: any = null; private _latestValue: any = null;

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Pipe, PipeTransform} from '@angular/core'; import {Injectable, Pipe, PipeTransform} from '@angular/core';
import {invalidPipeArgumentError} from './invalid_pipe_argument_error'; import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
/** /**
@ -24,6 +24,7 @@ import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
* @ngModule CommonModule * @ngModule CommonModule
* @publicApi * @publicApi
*/ */
@Injectable()
@Pipe({name: 'lowercase'}) @Pipe({name: 'lowercase'})
export class LowerCasePipe implements PipeTransform { export class LowerCasePipe implements PipeTransform {
/** /**
@ -67,6 +68,7 @@ const unicodeWordMatch =
* @ngModule CommonModule * @ngModule CommonModule
* @publicApi * @publicApi
*/ */
@Injectable()
@Pipe({name: 'titlecase'}) @Pipe({name: 'titlecase'})
export class TitleCasePipe implements PipeTransform { export class TitleCasePipe implements PipeTransform {
/** /**
@ -91,6 +93,7 @@ export class TitleCasePipe implements PipeTransform {
* @ngModule CommonModule * @ngModule CommonModule
* @publicApi * @publicApi
*/ */
@Injectable()
@Pipe({name: 'uppercase'}) @Pipe({name: 'uppercase'})
export class UpperCasePipe implements PipeTransform { export class UpperCasePipe implements PipeTransform {
/** /**

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Inject, LOCALE_ID, Pipe, PipeTransform} from '@angular/core'; import {Inject, Injectable, LOCALE_ID, Pipe, PipeTransform} from '@angular/core';
import {formatDate} from '../i18n/format_date'; import {formatDate} from '../i18n/format_date';
import {invalidPipeArgumentError} from './invalid_pipe_argument_error'; import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
@ -150,6 +150,7 @@ import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
* @publicApi * @publicApi
*/ */
// clang-format on // clang-format on
@Injectable()
@Pipe({name: 'date', pure: true}) @Pipe({name: 'date', pure: true})
export class DatePipe implements PipeTransform { export class DatePipe implements PipeTransform {
constructor(@Inject(LOCALE_ID) private locale: string) {} constructor(@Inject(LOCALE_ID) private locale: string) {}

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {LOCALE_ID, Pipe, PipeTransform} from '@angular/core'; import {Injectable, LOCALE_ID, Pipe, PipeTransform} from '@angular/core';
import {NgLocalization, getPluralCategory} from '../i18n/localization'; import {NgLocalization, getPluralCategory} from '../i18n/localization';
import {invalidPipeArgumentError} from './invalid_pipe_argument_error'; import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
@ -26,6 +26,7 @@ const _INTERPOLATION_REGEXP: RegExp = /#/g;
* *
* @publicApi * @publicApi
*/ */
@Injectable()
@Pipe({name: 'i18nPlural', pure: true}) @Pipe({name: 'i18nPlural', pure: true})
export class I18nPluralPipe implements PipeTransform { export class I18nPluralPipe implements PipeTransform {
constructor(private _localization: NgLocalization) {} constructor(private _localization: NgLocalization) {}

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Pipe, PipeTransform} from '@angular/core'; import {Injectable, Pipe, PipeTransform} from '@angular/core';
import {invalidPipeArgumentError} from './invalid_pipe_argument_error'; import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
/** /**
@ -26,6 +26,7 @@ import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
* *
* @publicApi * @publicApi
*/ */
@Injectable()
@Pipe({name: 'i18nSelect', pure: true}) @Pipe({name: 'i18nSelect', pure: true})
export class I18nSelectPipe implements PipeTransform { export class I18nSelectPipe implements PipeTransform {
/** /**

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Pipe, PipeTransform} from '@angular/core'; import {Injectable, Pipe, PipeTransform} from '@angular/core';
/** /**
* @ngModule CommonModule * @ngModule CommonModule
@ -23,6 +23,7 @@ import {Pipe, PipeTransform} from '@angular/core';
* *
* @publicApi * @publicApi
*/ */
@Injectable()
@Pipe({name: 'json', pure: false}) @Pipe({name: 'json', pure: false})
export class JsonPipe implements PipeTransform { export class JsonPipe implements PipeTransform {
/** /**

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {KeyValueChangeRecord, KeyValueChanges, KeyValueDiffer, KeyValueDiffers, Pipe, PipeTransform} from '@angular/core'; import {Injectable, KeyValueChangeRecord, KeyValueChanges, KeyValueDiffer, KeyValueDiffers, Pipe, PipeTransform} from '@angular/core';
function makeKeyValuePair<K, V>(key: K, value: V): KeyValue<K, V> { function makeKeyValuePair<K, V>(key: K, value: V): KeyValue<K, V> {
return {key: key, value: value}; return {key: key, value: value};
@ -43,6 +43,7 @@ export interface KeyValue<K, V> {
* *
* @publicApi * @publicApi
*/ */
@Injectable()
@Pipe({name: 'keyvalue', pure: false}) @Pipe({name: 'keyvalue', pure: false})
export class KeyValuePipe implements PipeTransform { export class KeyValuePipe implements PipeTransform {
constructor(private readonly differs: KeyValueDiffers) {} constructor(private readonly differs: KeyValueDiffers) {}

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Inject, LOCALE_ID, Pipe, PipeTransform} from '@angular/core'; import {Inject, Injectable, LOCALE_ID, Pipe, PipeTransform} from '@angular/core';
import {formatCurrency, formatNumber, formatPercent} from '../i18n/format_number'; import {formatCurrency, formatNumber, formatPercent} from '../i18n/format_number';
import {getCurrencySymbol} from '../i18n/locale_data_api'; import {getCurrencySymbol} from '../i18n/locale_data_api';
import {invalidPipeArgumentError} from './invalid_pipe_argument_error'; import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
@ -46,6 +46,7 @@ import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
* *
* @publicApi * @publicApi
*/ */
@Injectable()
@Pipe({name: 'number'}) @Pipe({name: 'number'})
export class DecimalPipe implements PipeTransform { export class DecimalPipe implements PipeTransform {
constructor(@Inject(LOCALE_ID) private _locale: string) {} constructor(@Inject(LOCALE_ID) private _locale: string) {}
@ -99,6 +100,7 @@ export class DecimalPipe implements PipeTransform {
* *
* @publicApi * @publicApi
*/ */
@Injectable()
@Pipe({name: 'percent'}) @Pipe({name: 'percent'})
export class PercentPipe implements PipeTransform { export class PercentPipe implements PipeTransform {
constructor(@Inject(LOCALE_ID) private _locale: string) {} constructor(@Inject(LOCALE_ID) private _locale: string) {}
@ -153,6 +155,7 @@ export class PercentPipe implements PipeTransform {
* *
* @publicApi * @publicApi
*/ */
@Injectable()
@Pipe({name: 'currency'}) @Pipe({name: 'currency'})
export class CurrencyPipe implements PipeTransform { export class CurrencyPipe implements PipeTransform {
constructor(@Inject(LOCALE_ID) private _locale: string) {} constructor(@Inject(LOCALE_ID) private _locale: string) {}

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Pipe, PipeTransform} from '@angular/core'; import {Injectable, Pipe, PipeTransform} from '@angular/core';
import {invalidPipeArgumentError} from './invalid_pipe_argument_error'; import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
/** /**
@ -44,6 +44,7 @@ import {invalidPipeArgumentError} from './invalid_pipe_argument_error';
* *
* @publicApi * @publicApi
*/ */
@Injectable()
@Pipe({name: 'slice', pure: false}) @Pipe({name: 'slice', pure: false})
export class SlicePipe implements PipeTransform { export class SlicePipe implements PipeTransform {
/** /**