fix(common): do not reference deprecated classes in providers (#14523) (#14523)

References to `NgFor` are now an alias for `NgForOf` instead of a
derived class.

Fixes #14521
This commit is contained in:
Chuck Jazdzewski
2017-02-23 17:23:56 -08:00
committed by Igor Minar
parent c53621be8e
commit a23634dfd0
5 changed files with 27 additions and 87 deletions
@@ -6,8 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {CommonModule} from '@angular/common';
import {Component} from '@angular/core';
import {CommonModule, NgFor, 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';
import {expect} from '@angular/platform-browser/testing/matchers';
@@ -29,7 +29,7 @@ export function main() {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [TestComponent],
declarations: [TestComponent, TestDirective],
imports: [CommonModule],
});
});
@@ -350,6 +350,14 @@ export function main() {
getComponent().items = ['e', 'f', 'h'];
detectChangesAndExpectText('efh');
}));
it('should support injecting `NgFor` and get an instance of `NgForOf`', async(() => {
const template = `<template ngFor [ngForOf]='items' let-item test></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);
}));
});
});
}
@@ -367,6 +375,11 @@ 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> {