Skip to content

Commit

Permalink
feat(cdk): improve rxIfList context
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbe812 committed Apr 11, 2023
1 parent 6e8f29c commit c2153b0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libs/cdk/template/src/lib/rx-if-list/rx-if-list.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class RxIfListDirective {
*/
@Input()
set rxIfList(value: ArrayLike<unknown> | null | undefined) {
this._context.$implicit = this._context.rxIfList = ((value?.length ?? []) > 0);
this._context.$implicit = this._context.rxIfList = value;
this._updateView();
}

Expand All @@ -79,7 +79,7 @@ export class RxIfListDirective {
}

private _updateView() {
if (this._context.$implicit) {
if (this._context.$implicit && (((this._context.$implicit as ArrayLike<any>)?.length ?? []) > 0)){
if (!this._thenViewRef) {
this._viewContainer.clear();
this._elseViewRef = null;
Expand All @@ -88,7 +88,7 @@ export class RxIfListDirective {
this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);
}
}
} else {
} else {
if (!this._elseViewRef) {
this._viewContainer.clear();
this._thenViewRef = null;
Expand All @@ -107,8 +107,8 @@ export class RxIfListDirective {
* @publicApi
*/
export class RxIfListContext {
$implicit = false;
rxIfList = false;
$implicit: ArrayLike<any> | null | undefined = null;
rxIfList: ArrayLike<any> | null | undefined = null;
}

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

0 comments on commit c2153b0

Please sign in to comment.