refactor(common): remove deprecated NgFor
(#18758)
BREAKING CHANGE: `NgFor` has been removed as it was deprecated since v4. Use `NgForOf` instead. This does not impact the use of`*ngFor` in your templates. PR Close #18758
This commit is contained in:

committed by
Miško Hevery

parent
7ce9e06dab
commit
ec56760c9b
@ -15,7 +15,7 @@ export * from './location/index';
|
||||
export {NgLocaleLocalization, NgLocalization} from './localization';
|
||||
export {parseCookieValue as ɵparseCookieValue} from './cookie';
|
||||
export {CommonModule, DeprecatedI18NPipesModule} from './common_module';
|
||||
export {NgClass, NgFor, NgForOf, NgForOfContext, NgIf, NgIfContext, NgPlural, NgPluralCase, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgTemplateOutlet, NgComponentOutlet} from './directives/index';
|
||||
export {NgClass, NgForOf, NgForOfContext, NgIf, NgIfContext, NgPlural, NgPluralCase, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgTemplateOutlet, NgComponentOutlet} from './directives/index';
|
||||
export {DOCUMENT} from './dom_tokens';
|
||||
export {AsyncPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, JsonPipe, LowerCasePipe, CurrencyPipe, DecimalPipe, PercentPipe, SlicePipe, UpperCasePipe, TitleCasePipe} from './pipes/index';
|
||||
export {PLATFORM_BROWSER_ID as ɵPLATFORM_BROWSER_ID, PLATFORM_SERVER_ID as ɵPLATFORM_SERVER_ID, PLATFORM_WORKER_APP_ID as ɵPLATFORM_WORKER_APP_ID, PLATFORM_WORKER_UI_ID as ɵPLATFORM_WORKER_UI_ID, isPlatformBrowser, isPlatformServer, isPlatformWorkerApp, isPlatformWorkerUi} from './platform_id';
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
import {NgModule} from '@angular/core';
|
||||
|
||||
import {COMMON_DEPRECATED_DIRECTIVES, COMMON_DIRECTIVES} from './directives/index';
|
||||
import {COMMON_DIRECTIVES} from './directives/index';
|
||||
import {NgLocaleLocalization, NgLocalization} from './localization';
|
||||
import {COMMON_PIPES} from './pipes/index';
|
||||
|
||||
|
@ -10,7 +10,7 @@ import {Provider} from '@angular/core';
|
||||
|
||||
import {NgClass} from './ng_class';
|
||||
import {NgComponentOutlet} from './ng_component_outlet';
|
||||
import {NgFor, NgForOf, NgForOfContext} from './ng_for_of';
|
||||
import {NgForOf, NgForOfContext} from './ng_for_of';
|
||||
import {NgIf, NgIfContext} from './ng_if';
|
||||
import {NgPlural, NgPluralCase} from './ng_plural';
|
||||
import {NgStyle} from './ng_style';
|
||||
@ -20,7 +20,6 @@ import {NgTemplateOutlet} from './ng_template_outlet';
|
||||
export {
|
||||
NgClass,
|
||||
NgComponentOutlet,
|
||||
NgFor,
|
||||
NgForOf,
|
||||
NgForOfContext,
|
||||
NgIf,
|
||||
@ -53,8 +52,3 @@ export const COMMON_DIRECTIVES: Provider[] = [
|
||||
NgPlural,
|
||||
NgPluralCase,
|
||||
];
|
||||
|
||||
/**
|
||||
* A collection of deprecated directives that are no longer part of the core module.
|
||||
*/
|
||||
export const COMMON_DEPRECATED_DIRECTIVES: Provider[] = [NgFor];
|
||||
|
@ -199,16 +199,6 @@ class RecordViewTuple<T> {
|
||||
constructor(public record: any, public view: EmbeddedViewRef<NgForOfContext<T>>) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated from v4.0.0 - Use NgForOf<any> instead.
|
||||
*/
|
||||
export type NgFor = NgForOf<any>;
|
||||
|
||||
/**
|
||||
* @deprecated from v4.0.0 - Use NgForOf instead.
|
||||
*/
|
||||
export const NgFor = NgForOf;
|
||||
|
||||
export function getTypeNameForDebugging(type: any): string {
|
||||
return type['name'] || typeof type;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {CommonModule, NgFor, NgForOf} from '@angular/common';
|
||||
import {CommonModule, NgForOf} from '@angular/common';
|
||||
import {Component, Directive} from '@angular/core';
|
||||
import {ComponentFixture, TestBed, async} from '@angular/core/testing';
|
||||
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||
@ -29,7 +29,7 @@ export function main() {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [TestComponent, TestDirective],
|
||||
declarations: [TestComponent],
|
||||
imports: [CommonModule],
|
||||
});
|
||||
});
|
||||
@ -358,14 +358,6 @@ export function main() {
|
||||
getComponent().items = ['e', 'f', 'h'];
|
||||
detectChangesAndExpectText('efh');
|
||||
}));
|
||||
|
||||
it('should support injecting `NgFor` and get an instance of `NgForOf`', async(() => {
|
||||
const template = `<ng-template ngFor [ngForOf]='items' let-item test></ng-template>`;
|
||||
fixture = createTestComponent(template);
|
||||
const testDirective = fixture.debugElement.childNodes[0].injector.get(TestDirective);
|
||||
const ngForOf = fixture.debugElement.childNodes[0].injector.get(NgForOf);
|
||||
expect(testDirective.ngFor).toBe(ngForOf);
|
||||
}));
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -383,11 +375,6 @@ class TestComponent {
|
||||
trackByContext(): void { thisArg = this; }
|
||||
}
|
||||
|
||||
@Directive({selector: '[test]'})
|
||||
class TestDirective {
|
||||
constructor(public ngFor: NgFor) {}
|
||||
}
|
||||
|
||||
const TEMPLATE = '<div><span *ngFor="let item of items">{{item.toString()}};</span></div>';
|
||||
|
||||
function createTestComponent(template: string = TEMPLATE): ComponentFixture<TestComponent> {
|
||||
|
@ -17,7 +17,7 @@ import {Optional, SkipSelf, StaticProvider} from '../../di';
|
||||
export type NgIterable<T> = Array<T>| Iterable<T>;
|
||||
|
||||
/**
|
||||
* A strategy for tracking changes over time to an iterable. Used by {@link NgFor} to
|
||||
* A strategy for tracking changes over time to an iterable. Used by {@link NgForOf} to
|
||||
* respond to changes in an iterable by effecting equivalent changes in the DOM.
|
||||
*
|
||||
* @stable
|
||||
|
Reference in New Issue
Block a user