当前位置: 首页>>代码示例>>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;未经允许,请勿转载。