本文整理汇总了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));
开发者ID:eskab,项目名称:Sample-TS-App,代码行数:18,代码来源:main.ts
示例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);
开发者ID:Bill0106,项目名称:MySite,代码行数:10,代码来源:app.ts
示例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) {
开发者ID:aroux,项目名称:myangular2-seed,代码行数:31,代码来源:main.ts
示例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;
}
})
//.........这里部分代码省略.........
开发者ID:Urigo,项目名称:angular-meteor,代码行数:101,代码来源:main.ts
注:本文中的@angular/core.enableProdMode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论