本文整理汇总了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;
}
})
//.........这里部分代码省略.........