Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what exactly happens when `enableProdMode()` [duplicate]

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?

like image 802
Jitendra Tiwari Avatar asked May 19 '16 08:05

Jitendra Tiwari


People also ask

What does enableProdMode do in angular?

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

How do I call in enableProdMode?

You enable it by importing and executing the function (before calling bootstrap): import {enableProdMode} from '@angular/core'; enableProdMode(); bootstrap(....); But this error is indicator that something is wrong with your bindings, so you shouldn't just dismiss it, but try to figure out why it's happening.

How do I enable production mode in angular 8?

Call enableProdMode() to enable the production mode.


Video Answer


2 Answers

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...

like image 67
Thierry Templier Avatar answered Oct 04 '22 15:10

Thierry Templier


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.

like image 37
user7208727 Avatar answered Oct 04 '22 16:10

user7208727