本文整理汇总了TypeScript中angular2-universal.enableProdMode函数的典型用法代码示例。如果您正苦于以下问题:TypeScript enableProdMode函数的具体用法?TypeScript enableProdMode怎么用?TypeScript enableProdMode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了enableProdMode函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: generateHtml
export function generateHtml(opts: Options): Promise<string> {
opts = Object.assign({
originUrl: "http://localhost:8080",
baseUrl: "/",
reqUrl: "/",
preboot: false,
}, opts);
let config: CliBootloaderConfig = {
directives: [opts.component],
platformProviders: [
provide(ORIGIN_URL, { useValue: opts.originUrl }),
provide(BASE_URL, { useValue: opts.baseUrl }),
],
providers: [
provide(REQUEST_URL, { useValue: opts.reqUrl }),
...NODE_ROUTER_PROVIDERS,
...NODE_HTTP_PROVIDERS,
],
beautify: true,
async: true,
};
enableProdMode();
let doc = Bootloader.parseDocument(opts.templateHtml);
config.document = doc;
config.template = opts.templateHtml;
config.preboot = opts.preboot;
let bootloader = new Bootloader(config);
return bootloader.serializeApplication();
}
示例2: express
expressEngine,
REQUEST_URL,
ORIGIN_URL,
BASE_URL,
NODE_ROUTER_PROVIDERS,
NODE_HTTP_PROVIDERS,
ExpressEngineConfig
} from 'angular2-universal';
// replace this line with your Angular 2 root component
import {App} from './app/app';
const app = express();
const ROOT = path.join(path.resolve(__dirname, '..'));
enableProdMode();
// Express View
app.engine('.html', expressEngine);
app.set('views', './src');
app.set('view engine', 'html');
app.use(bodyParser.json());
function ngApp(req, res) {
let baseUrl = '/';
let url = req.originalUrl || '/';
let config: ExpressEngineConfig = {
directives: [
App