fix(common): properly update collection reference in NgForOf (#24684)
closes #24155 PR Close #24684
This commit is contained in:
parent
87ddbdf919
commit
ff84c5c4da
|
@ -182,6 +182,7 @@ export class NgForOf<T> implements DoCheck {
|
|||
const viewRef = <EmbeddedViewRef<NgForOfContext<T>>>this._viewContainer.get(i);
|
||||
viewRef.context.index = i;
|
||||
viewRef.context.count = ilen;
|
||||
viewRef.context.ngForOf = this._ngForOf;
|
||||
}
|
||||
|
||||
changes.forEachIdentityChange((record: any) => {
|
||||
|
|
|
@ -183,9 +183,12 @@ let thisArg: any;
|
|||
|
||||
it('should allow of saving the collection', async(() => {
|
||||
const template =
|
||||
'<ul><li *ngFor="let item of [1,2,3] as items; index as i">{{i}}/{{items.length}} - {{item}};</li></ul>';
|
||||
'<ul><li *ngFor="let item of items as collection; index as i">{{i}}/{{collection.length}} - {{item}};</li></ul>';
|
||||
fixture = createTestComponent(template);
|
||||
|
||||
detectChangesAndExpectText('0/2 - 1;1/2 - 2;');
|
||||
|
||||
getComponent().items = [1, 2, 3];
|
||||
detectChangesAndExpectText('0/3 - 1;1/3 - 2;2/3 - 3;');
|
||||
}));
|
||||
|
||||
|
|
Loading…
Reference in New Issue