I have a situation where I need to pass a query parameter to an *ngIf
, but it keeps evaluating as true because it's in string format. How can I convert the query parameter to a boolean so that it evaluates as false?
The current query param is ?paywall=true
and even when using ?paywall=false
, it still evaluates as true.
In my component.ts file:
ngOnInit() {
this.paywallQuery$ = this.route.queryParamMap.pipe(map(params => params.get('paywall')));
}
And in my component.html file:
<div *ngIf="(paywallQuery$ | async)"> <-- always evaluating as true
</div>