When an exception is caught by Angular 2\'s exception handler, the UI no longer \'updates\'.
I have a very simple example here:
Don't rely on code execution after an unhandled Exception
happened.
You have to handle the exception in the place where you expect it to happen.
Error handling: http://www.javascriptkit.com/javatutors/trycatch.shtml
Since angular 4.1.1 (2017-05-04) https://github.com/angular/angular/commit/07cef36
fix(core): don’t stop change detection because of errors
- prevents unsubscribing from the zone on error
- prevents unsubscribing from directive
EventEmitter
s on error- prevents detaching views in dev mode if there on error
- ensures that
ngOnInit
is only called 1x (also in prod mode)
it should work without additional code
@Component({
selector: 'my-app',
template : `
{{aValue}}
<button (click)='doIt()'>do it</button>
<button (click)='breakIt()'>break it</button>
`
})
export class App implements OnInit {
private aValue: boolean = true
doIt(){
console.log('Doing It')
this.aValue = !this.aValue
}
breakIt(){
console.log('Breaking It')
throw new Error('some error')
}
}
Plunker Example