add error handler
This commit is contained in:
parent
02e1ecfe82
commit
c6c2c5abb7
8
src/app/ErrorHandler.ts
Normal file
8
src/app/ErrorHandler.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import {ErrorHandler as NgErrorHandler} from "@angular/core";
|
||||
|
||||
|
||||
export class ErrorHandler implements NgErrorHandler {
|
||||
handleError(error: any): void {
|
||||
console.warn(error);
|
||||
}
|
||||
}
|
@ -8,6 +8,8 @@ import localeJap from "@angular/common/locales/en"
|
||||
import {provideHttpClient} from "@angular/common/http";
|
||||
import {InMemoryWebApiModule} from "angular-in-memory-web-api";
|
||||
import {HotelDataService} from "./hotel/service/HotelData.service";
|
||||
import {ErrorHandler} from "./ErrorHandler";
|
||||
import {ErrorHandler as NgErrorHandler} from "@angular/core";
|
||||
|
||||
registerLocaleData(localeDe, 'de-DE')
|
||||
registerLocaleData(localeCn, 'cn-CN')
|
||||
@ -17,6 +19,10 @@ export const appConfig: ApplicationConfig = {
|
||||
provideZoneChangeDetection({ eventCoalescing: true }),
|
||||
provideRouter(routes),
|
||||
provideHttpClient(),
|
||||
importProvidersFrom(InMemoryWebApiModule.forRoot(HotelDataService))
|
||||
importProvidersFrom(InMemoryWebApiModule.forRoot(HotelDataService)),
|
||||
{
|
||||
provide: NgErrorHandler,
|
||||
useClass: ErrorHandler
|
||||
}
|
||||
]
|
||||
};
|
||||
|
@ -106,7 +106,9 @@ export class EditHotelComponent implements OnInit {
|
||||
debounce = 0;
|
||||
}
|
||||
|
||||
control?.valueChanges?.pipe(debounceTime(debounce)).subscribe(() => {this.setErrorMessage(controlName, control)});
|
||||
control?.valueChanges?.pipe(debounceTime(debounce)).subscribe(() => {
|
||||
this.setErrorMessage(controlName, control)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user