What is the difference between production and development mode in Angular2?

Rhushikesh picture Rhushikesh · Jan 19, 2016 · Viewed 43.6k times · Source

For some reason, I have to run my app in production mode. What is the difference between those modes?

Answer

Günter Zöchbauer picture Günter Zöchbauer · Jan 19, 2016

In development mode, change detection does a second run immediately after the first run and produces an error if any bound value has changed between the first and the second run. This helps to locate bugs where checking values has side-effects or fields or functions don't return the same value on subsequent calls which undermines Angular's change detection.

In development mode, during the second change detection run, Angular also does some deep object comparisons that it won't do in production to detect model changes that are disallowed.

Update:

In development mode, a hint is also printed to the console when the HTML sanitizer service strips values from bindings [innerHTML]="..." or [ngStyle]="...". See also: In RC.1 some styles can't be added using binding syntax