當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript angular2-hmr.hotModuleReplacement函數代碼示例

本文整理匯總了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());
    }
}
開發者ID:bromzh,項目名稱:angular2-webpack-starter,代碼行數:11,代碼來源:environment.ts

示例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());
}
開發者ID:bradmaxs,項目名稱:angular2-typescript-webpack,代碼行數:30,代碼來源:main.browser.ts

示例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());
}
開發者ID:Polvista,項目名稱:ng2-seed,代碼行數:31,代碼來源:main.ts

示例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());
}
開發者ID:lucianferoiu,項目名稱:angular2-seed,代碼行數:26,代碼來源:main.browser.ts

示例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);
開發者ID:vijays,項目名稱:ng2-weather,代碼行數:12,代碼來源:boot.ts


注:本文中的angular2-hmr.hotModuleReplacement函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。