|
1 |
| -import { AfterContentInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, Directive, DoCheck, ElementRef, EmbeddedViewRef, EventEmitter, forwardRef, Host, HostListener, Inject, InjectionToken, Input, IterableDiffer, IterableDiffers, OnDestroy, Output, TemplateRef, ViewChild, ViewContainerRef, ɵisListLikeIterable as isListLikeIterable } from '@angular/core'; |
| 1 | +import { AfterContentInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, Directive, DoCheck, ElementRef, EmbeddedViewRef, EventEmitter, forwardRef, Host, HostListener, inject, Inject, InjectionToken, Input, IterableDiffer, IterableDiffers, NgZone, OnDestroy, Output, TemplateRef, ViewChild, ViewContainerRef, ɵisListLikeIterable as isListLikeIterable } from '@angular/core'; |
2 | 2 | import { ItemEventData, KeyedTemplate, LayoutBase, ListView, ObservableArray, profile, View } from '@nativescript/core';
|
3 | 3 |
|
4 | 4 | import { extractSingleViewRecursive } from '../../element-registry/registry';
|
@@ -96,7 +96,12 @@ export class ListViewComponent<T = any> implements DoCheck, OnDestroy, AfterCont
|
96 | 96 | return this.templatedItemsView;
|
97 | 97 | }
|
98 | 98 |
|
99 |
| - protected templatedItemsView: ListView; |
| 99 | + private readonly _iterableDiffers: IterableDiffers = inject(IterableDiffers); |
| 100 | + private readonly _changeDetectorRef: ChangeDetectorRef = inject(ChangeDetectorRef); |
| 101 | + private readonly _elementRef: ElementRef = inject(ElementRef); |
| 102 | + |
| 103 | + // I believe this only exists so this can be inherited and people can override it. |
| 104 | + protected templatedItemsView: ListView = this._elementRef.nativeElement; |
100 | 105 | protected _items: T[] | ObservableArray<T>;
|
101 | 106 | protected _differ: IterableDiffer<T>;
|
102 | 107 | protected _templateMap: Map<string, NsTemplatedItem<T>>;
|
@@ -130,8 +135,24 @@ export class ListViewComponent<T = any> implements DoCheck, OnDestroy, AfterCont
|
130 | 135 | this.templatedItemsView.items = this._items;
|
131 | 136 | }
|
132 | 137 |
|
133 |
| - constructor(_elementRef: ElementRef, private readonly _iterableDiffers: IterableDiffers, private readonly _changeDetectorRef: ChangeDetectorRef) { |
134 |
| - this.templatedItemsView = _elementRef.nativeElement; |
| 138 | + /** |
| 139 | + * @deprecated |
| 140 | + */ |
| 141 | + constructor(_elementRef: ElementRef); |
| 142 | + /** |
| 143 | + * @deprecated |
| 144 | + */ |
| 145 | + constructor(_elementRef: ElementRef, _iterableDiffers: IterableDiffers, _changeDetectorRef: ChangeDetectorRef); |
| 146 | + /** |
| 147 | + * @deprecated |
| 148 | + */ |
| 149 | + constructor(_elementRef: ElementRef, _iterableDiffers: IterableDiffers, _ngZone: NgZone); |
| 150 | + constructor(); |
| 151 | + // this elementRef is only here for backwards compatibility reasons |
| 152 | + constructor(_elementRef?: ElementRef) { |
| 153 | + if (_elementRef) { |
| 154 | + this.templatedItemsView = _elementRef.nativeElement; |
| 155 | + } |
135 | 156 | }
|
136 | 157 |
|
137 | 158 | ngAfterContentInit() {
|
|
0 commit comments