Skip to content

Commit c2153b0

Browse files
committed
feat(cdk): improve rxIfList context
1 parent 6e8f29c commit c2153b0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

libs/cdk/template/src/lib/rx-if-list/rx-if-list.directive.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class RxIfListDirective {
5252
*/
5353
@Input()
5454
set rxIfList(value: ArrayLike<unknown> | null | undefined) {
55-
this._context.$implicit = this._context.rxIfList = ((value?.length ?? []) > 0);
55+
this._context.$implicit = this._context.rxIfList = value;
5656
this._updateView();
5757
}
5858

@@ -79,7 +79,7 @@ export class RxIfListDirective {
7979
}
8080

8181
private _updateView() {
82-
if (this._context.$implicit) {
82+
if (this._context.$implicit && (((this._context.$implicit as ArrayLike<any>)?.length ?? []) > 0)){
8383
if (!this._thenViewRef) {
8484
this._viewContainer.clear();
8585
this._elseViewRef = null;
@@ -88,7 +88,7 @@ export class RxIfListDirective {
8888
this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);
8989
}
9090
}
91-
} else {
91+
} else {
9292
if (!this._elseViewRef) {
9393
this._viewContainer.clear();
9494
this._thenViewRef = null;
@@ -107,8 +107,8 @@ export class RxIfListDirective {
107107
* @publicApi
108108
*/
109109
export class RxIfListContext {
110-
$implicit = false;
111-
rxIfList = false;
110+
$implicit: ArrayLike<any> | null | undefined = null;
111+
rxIfList: ArrayLike<any> | null | undefined = null;
112112
}
113113

114114
function assertTemplate(property: string, templateRef: TemplateRef<any>|null): void {

0 commit comments

Comments
 (0)