38

I'm working with Angular2 quick start demo using TypeScript. Everything is working fine with this but after completion of demo I have seen a message in my browser console

Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.

I have done this with the help of this answer.

import { bootstrap } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app.component';
import { enableProdMode } from '@angular/core';

enableProdMode();
bootstrap(AppComponent);

Question

  1. What exactly happens when app move to production mode?
  2. I have not seen any changes in application behavior except removing console message?

Can anyone explain please?

Community
  • 1
  • 1
Jitendra Tiwari
  • 1,651
  • 3
  • 14
  • 28
  • 2
    Does this Günter's answer fit your expectation? http://stackoverflow.com/questions/34868810/what-is-diff-between-production-and-development-mode-in-angular2 – Thierry Templier May 19 '16 at 08:35
  • @ThierryTemplier I was expecting this when enabling prod mode but change detection was still running after `enableProdMode()`. I have modify a file after enabling this, the browser is automatically refresh. – Jitendra Tiwari May 19 '16 at 09:53

3 Answers3

12

Enabling the production mode won't disable change detection. This feature is the foundation of Angular2 to synchronize the template with the state of the associated class.

With production mode, only one run is done not two...

Thierry Templier
  • 198,364
  • 44
  • 396
  • 360
  • 9
    I'm sorry but not clear more... – Jitendra Tiwari May 19 '16 at 17:05
  • 2
    I mean change detection is always used both in dev and prod mode. In dev mode, the change detection is run once and a second time right after. Change detection is triggered by ZoneJS. Perhaps this Mark Rajcok's awesome answer could help you to understand what happens under the hood: http://stackoverflow.com/questions/34569094/what-is-the-angular2-equivalent-to-an-angularjs-watch. I'm aware that it's not so obvious ;-) – Thierry Templier May 19 '16 at 17:09
6

enableProMode

Disable Angular's development mode, which turns off assertions and other checks within the framework.

One important assertion this disables verifies that a change detection pass does not result in additional changes to any bindings (also known as unidirectional data flow).

@stable

isDevMode

Returns whether Angular is in development mode. After called once, the value is locked and won't change any more.

By default, this is true, unless a user calls enableProdMode before calling this.

@experimental APIs related to application bootstrap are currently under review.

kayess
  • 3,384
  • 9
  • 28
  • 45
user7208727
  • 89
  • 1
  • 1
3

According to Angular 2 Documentation: https://angular.io/docs/ts/latest/api/core/index/enableProdMode-function.html

Disable Angular's development mode, which turns off assertions and other checks within the framework.

One important assertion this disables verifies that a change detection pass does not result in additional changes to any bindings (also known as unidirectional data flow).

Community
  • 1
  • 1
Andyccs
  • 520
  • 3
  • 9