I'm using Angular 2.4.9 and have implemented a custom error handler which just catches all errors and navigates to an error route to display the message.
I have a toggle button to show/hide a detailed message which is bound to a boolean (also tried a boolean within an object i.e. object.showError) All works correctly if im catching Http errors and throwing an error myself. However if I encounter an Angular error such as ViewWrappedError the databinding refuses to work. (click) evets still function and the boolean is toggled from true to false its just the changes are not reflected on the page.
Am I missing something to get this to work?
import { Component } from '@angular/core';
import { ErrorService } from './error.service';
import { Error } from './index';
@Component({
moduleId: module.id,
selector: 'error',
templateUrl: 'error.component.html',
styleUrls: ['error.component.css']
})
export class ErrorComponent {
public error: Error;
public showDetailedError: boolean;
constructor(private errorService: ErrorService) {
this.showDetailedError = false;
this.error = this.errorService.getError();
}
}
HTML Template
<div class="error-container">
<h1>Sorry, something went wrong.</h1>
<p class="error-message">An error occurred while processing your request. Details on this error can be found below.</p>
</div>
<p *ngIf="!showDetailedError" (click)="showDetailedError = !showDetailedError" class="info-icon">Click for detailed description</p>
</div>