I'm getting NG0100 error (Expression changed) in my console. Is there any way I can catch this error in my code and print it in the console via my code?
I tried try catch block but it doesn't seem to be working.
try{
//error generating code
}
catch(e){
console.log(e.message)
}
Thanks!
Actually, catch a NG0100 won't help that much. It's not a blocking error, it's just a big warning to tell yout that your code is unsafe and some expressions change at a point of the component genereation where it shouldn't.
It is supported by Angular DoubleCheck wich is a system that check your template binded attributes to make sure your code is stable and predictable. NG0100 means your expression has changed between these two checks. It is just a warning because this DoubleCheck only exists in devmode (aka ng serve or ng build --configuration developement).
Best you can do is find why and where this happens in your code, to avoid it. The informations given can't let us know, but you can watch this video from Angular official documentation that explains most common reasons of NG0100