本文整理匯總了TypeScript中@angular/core.enableProdMode函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript enableProdMode函數的具體用法?TypeScript enableProdMode怎麽用?TypeScript enableProdMode使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了enableProdMode函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: enableProdMode
import { enableProdMode } from '@angular/core';
import { bootstrap } from '@angular/platform-browser-dynamic';
import { HTTP_PROVIDERS } from '@angular/http';
import { AppComponent } from './app/app.component';
import { APP_ROUTER_PROVIDERS } from './app/app.routes';
// depending on the env mode, enable prod mode or add debugging modules
if (process.env.ENV === 'build') {
enableProdMode();
}
bootstrap(AppComponent, [
// Array with dependiences of our application
HTTP_PROVIDERS,
APP_ROUTER_PROVIDERS
])
.catch(err => console.error(err));
示例2: platformBrowserDynamic
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
const platform = platformBrowserDynamic();
enableProdMode(); // Comment this line when in developer mode
platform.bootstrapModule(AppModule);
示例3: disableDeprecatedForms
import { APP_BASE_HREF } from '@angular/common';
import { disableDeprecatedForms, provideForms } from '@angular/forms';
import { enableProdMode } from '@angular/core';
import { bootstrap } from '@angular/platform-browser-dynamic';
import { APP_ROUTER_PROVIDERS } from './app.routes';
import { AppComponent } from './app.component';
if ('<%= ENV %>' === 'prod') { enableProdMode(); }
//enableProdMode();
/**
* Bootstraps the application and makes the ROUTER_PROVIDERS and the APP_BASE_HREF available to it.
* @see https://angular.io/docs/ts/latest/api/platform-browser-dynamic/index/bootstrap-function.html
*/
bootstrap(AppComponent, [
disableDeprecatedForms(),
provideForms(),
APP_ROUTER_PROVIDERS,
{
provide: APP_BASE_HREF,
useValue: '<%= APP_BASE %>'
}
]);
// In order to start the Service Worker located at "./worker.js"
// uncomment this line. More about Service Workers here
// https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers
//
// if ('serviceWorker' in navigator) {
示例4: enableProdMode
Meteor.startup(() => {
// Enable Angular's production mode if Meteor is in production mode
if (Meteor.isProduction) {
enableProdMode();
}
// When page requested
WebAppInternals.registerBoilerplateDataCallback('angular', async (request, data) => {
let document,
platformRef: PlatformRef;
// Handle Angular's error, but do not prevent client bootstrap
try {
document = `
<html>
<head>
<base href="/">
</head>
<body>
<app></app>
</body>
</html>
`;
// Integrate Angular's router with Meteor
const url = request.url;
// Get rendered document
platformRef = platformDynamicServer([
{
provide: INITIAL_CONFIG,
useValue: {
// Initial document
document,
url
}
}
]);
const appModuleRef = await platformRef.bootstrapModule(ServerAppModule, {
ngZone: 'noop',
providers: [
{
provide: ResourceLoader,
useValue: {
get: Assets.getText
},
deps: []
}
]
});
const applicationRef: ApplicationRef = appModuleRef.injector.get(ApplicationRef);
await applicationRef.isStable.pipe(
first(isStable => isStable == true)
).toPromise();
applicationRef.tick();
// Run any BEFORE_APP_SERIALIZED callbacks just before rendering to string.
const callbacks = appModuleRef.injector.get(BEFORE_APP_SERIALIZED, null);
if (callbacks) {
for (const callback of callbacks) {
try {
callback();
} catch (e) {
// Ignore exceptions.
console.warn('Ignoring BEFORE_APP_SERIALIZED Exception: ', e);
}
}
}
const platformState: PlatformState = appModuleRef.injector.get(PlatformState);
document = platformState.renderToString();
} catch (e) {
// Write errors to console
console.error('Angular SSR Error: ' + e.stack || e);
} finally {
//Make sure platform is destroyed before rendering
if (platformRef) {
platformRef.destroy();
}
const head = HEAD_REGEX.exec(document)[1];
data.dynamicHead = head;
const body = BODY_REGEX.exec(document)[1];
data.dynamicBody = body;
}
})
//.........這裏部分代碼省略.........