本文整理汇总了TypeScript中angular2-hmr.hotModuleReplacement函数的典型用法代码示例。如果您正苦于以下问题:TypeScript hotModuleReplacement函数的具体用法?TypeScript hotModuleReplacement怎么用?TypeScript hotModuleReplacement使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hotModuleReplacement函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: require
export function enableHotModuleReload<T>(bootloader: () => Promise<ComponentRef<T>>, module: any) {
if ('development' === ENV && HMR === true) {
// activate hot module reload
let ngHmr: HotModuleReplacer = require('angular2-hmr');
ngHmr.hotModuleReplacement(bootloader, module);
} else {
// bootstrap when document is ready
document.addEventListener('DOMContentLoaded', () => bootloader());
}
}
示例2: main
export function main(initialState = {}) {
let APP_PROVIDERS = [
provideInitialState(initialState),
AppState
];
return bootstrap(AppComponent , [
...ENV_PROVIDERS,
...PROVIDERS,
...DIRECTIVES,
...PIPES,
...APP_PROVIDERS
])
.catch(err => console.error(err));
}
/*
* Vendors
* For vendors for example jQuery, Lodash, angular2-jwt just import them anywhere in your app
* You can also import them in vendors to ensure that they are bundled in one file
* Also see custom-typings.d.ts as you also need to do `typings install x` where `x` is your module
*/
if ('development' === ENV && HMR === true) {
// activate hot module reload
hotModuleReplacement(main, module);
} else {
// bootstrap when documetn is ready
document.addEventListener('DOMContentLoaded', () => main());
}
示例3: enableProdMode
import { App } from "./AppComponent";
import { routes } from "./routes/routes";
/*
import { HTTP_PROVIDERS } from "@angular/http";
*/
import { NgRedux } from 'ng2-redux';
import { enableProdMode } from '@angular/core';
import { provideRouter, RouterConfig } from '@angular/router';
if (process.env.ENV === 'production') {
enableProdMode();
}
const bootstrapApp = (initialHMRstate?: any): Promise<any> => {
return bootstrap(App,
[
/*HTTP_PROVIDERS,
ROUTER_PROVIDERS,*/
/*NgRedux*/
provideRouter(routes)
]
);
};
if (process.env.ENV === 'development') {
let ngHmr = require('angular2-hmr');
ngHmr.hotModuleReplacement(bootstrapApp, module);
} else {
document.addEventListener('DOMContentLoaded', () => bootstrapApp());
}
示例4: main
import {LocationStrategy, HashLocationStrategy} from '@angular/common';
import {bootstrap} from '@angular/platform-browser-dynamic';
import {HTTP_PROVIDERS} from '@angular/http';
import {App} from './app/app';
// import {enableProdMode} from '@angular/core';
// enableProdMode()
function main(initialHmrState?: any): Promise<any> {
return bootstrap(App, [
HTTP_PROVIDERS,
{ provide: LocationStrategy, useClass: HashLocationStrategy }
])
.catch(err => console.error(err));
}
export let isDevelopmentMode = true;
if (isDevelopmentMode) {
// activate hot module reload
let ngHmr = require('angular2-hmr');
ngHmr.hotModuleReplacement(main, module); // pass the main function
} else {
// bootstrap when document is ready
document.addEventListener('DOMContentLoaded', () => main());
}
示例5: boot
import * as browser from 'angular2/platform/browser';
import {AppComponent} from './app/app';
import {HTTP_PROVIDERS} from 'angular2/http';
export function boot(){
return browser.bootstrap(AppComponent, [HTTP_PROVIDERS]);
}
// Activate hot module reload
let ngHmr = require('angular2-hmr');
ngHmr.hotModuleReplacement(boot, module);