How to avoid restarting angular live dev server after JIT compilation fails?

Viewed 148

On numerous occasions I have found myself making a typo or using the wrong syntax in my angular template which causes angular to fail the JIT compilation. This is fine, I will just fix my typo and all will be good right?

Wrong.

Now angular suddenly forgets what directives are and I get errors like: Can't bind to 'ngIf' since it isn't a known property of 'div'

The solution has been to shut down the live dev server and restart it. My computer is slow and this app is large so that means I'm going to be waiting for everything to recompile for a minute or two all because of a typo in the template!

Is there anything I can do to keep the live dev server running and remind angular what directives are? Maybe just recompile the modules or something like that?

1 Answers

Sometimes it helps to change something in the ts file of the current module or app module to force angular to recompile from higher in the code hierarchy. could also try to ' touch' multiple files at once ( e.g. both app module & feature module ts )

Related