When an exception is caught by Angular 2's exception handler, the UI no longer 'updates'.
I have a very simple example here:
import { Component, ExceptionHandler, Injectable, OnInit, provide } from '@angular/core';
import { bootstrap } from '@angular/platform-browser-dynamic';
import { Subject } from 'rxjs/Subject'
export interface Alert {
message: string;
}
@Component({
selector: 'my-app',
template : `
<h3>Parent</h3>
{{aValue}}
<br/>
<br/>
<button (click)='doIt()'>do it</button>
<br/>
<br/>
<button (click)='breakIt()'>break it</button>
`
})
export class App implements OnInit {
private aValue: boolean = true
constructor() { }
alerts: Alert[] = [];
doIt(){
console.log('Doing It')
this.aValue = !this.aValue
}
breakIt(){
console.log('Breaking It')
throw new Error('some error')
}
}
bootstrap(App).catch(err => console.error(err));
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…