From 0724222346259611cfa521e747e1cc4160e3e120 Mon Sep 17 00:00:00 2001 From: Nagesh Andani Date: Sat, 1 Nov 2025 14:30:30 +0530 Subject: [PATCH] chore: refactor *ngIf to use @if syntax --- .../components/nav-bar/nav-bar.component.html | 41 ++++++++++-------- .../src/app/pages/error/error.component.html | 4 +- .../src/app/pages/error/error.component.ts | 15 ++++--- .../external-api/external-api.component.html | 30 +++++++------ .../src/app/pages/home/home.component.html | 12 +++--- .../app/pages/profile/profile.component.html | 42 ++++++++++--------- 6 files changed, 81 insertions(+), 63 deletions(-) diff --git a/Standalone/src/app/components/nav-bar/nav-bar.component.html b/Standalone/src/app/components/nav-bar/nav-bar.component.html index 0bf1d037..b908272e 100644 --- a/Standalone/src/app/components/nav-bar/nav-bar.component.html +++ b/Standalone/src/app/components/nav-bar/nav-bar.component.html @@ -24,26 +24,28 @@ - - + @if (auth.isAuthenticated$ | async) { + + + } + @if ((auth.isAuthenticated$ | async) === false) { + } + @if (auth.user$ | async; as user) { + } diff --git a/Standalone/src/app/pages/error/error.component.html b/Standalone/src/app/pages/error/error.component.html index d1f0aeb6..bd441287 100644 --- a/Standalone/src/app/pages/error/error.component.html +++ b/Standalone/src/app/pages/error/error.component.html @@ -1,9 +1,9 @@
- +@if (error$ | async; as error) {

An error was returned from Auth0

Something went wrong when trying to authorize your application. Please inspect the error below and ensure auth_config.json is configured correctly.

-
+}
diff --git a/Standalone/src/app/pages/error/error.component.ts b/Standalone/src/app/pages/error/error.component.ts index 8d10244d..fd011e99 100644 --- a/Standalone/src/app/pages/error/error.component.ts +++ b/Standalone/src/app/pages/error/error.component.ts @@ -1,25 +1,30 @@ -import { AsyncPipe, NgIf } from '@angular/common'; +import { AsyncPipe } from '@angular/common'; import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { AuthService } from '@auth0/auth0-angular'; import { Observable, timer } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; +interface Auth0Error extends Error { + error_description?: string; + error?: string; + error_uri?: string; +} + @Component({ selector: 'app-error', templateUrl: './error.component.html', standalone: true, imports: [ - AsyncPipe, - NgIf + AsyncPipe ] }) export class ErrorComponent implements OnInit { - public error$: Observable; + public error$: Observable; constructor(private auth: AuthService, private router: Router) { - this.error$ = this.auth.error$; + this.error$ = this.auth.error$ as Observable; } ngOnInit() { diff --git a/Standalone/src/app/pages/external-api/external-api.component.html b/Standalone/src/app/pages/external-api/external-api.component.html index 3c3b71c0..cc8793cd 100644 --- a/Standalone/src/app/pages/external-api/external-api.component.html +++ b/Standalone/src/app/pages/external-api/external-api.component.html @@ -1,10 +1,12 @@

External API

- + @if (hasApiError) { + + }

Ping an external API by clicking the button below.

@@ -15,7 +17,7 @@

External API

API's audience value.

- + @if (!audience) { - + }

Ping an external API by clicking the button below. This will call the @@ -66,12 +68,14 @@

External API

Ping API -
-
-
Result
-
-        
-      
+ @if (responseJson) { +
+
+
Result
+
+          
+        
+
-
+ }
diff --git a/Standalone/src/app/pages/home/home.component.html b/Standalone/src/app/pages/home/home.component.html index cb35b745..f7100936 100644 --- a/Standalone/src/app/pages/home/home.component.html +++ b/Standalone/src/app/pages/home/home.component.html @@ -1,8 +1,8 @@ -
- -
- - +@if (auth.isLoading$ | async) { +
+ +
+} @else { -
+} diff --git a/Standalone/src/app/pages/profile/profile.component.html b/Standalone/src/app/pages/profile/profile.component.html index aaaf3d6b..d723d8c0 100644 --- a/Standalone/src/app/pages/profile/profile.component.html +++ b/Standalone/src/app/pages/profile/profile.component.html @@ -1,22 +1,26 @@ -
-
-
- +@if (auth.user$ | async; as user) { +
+
+
+ +
+
+

{{ user.name }}

+

{{ user.email }}

+
-
-

{{ user.name }}

-

{{ user.email }}

-
-
-
-
+ @if (profileJson) { +
+
+
+ }
-
+} \ No newline at end of file