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


TypeScript core.enableProdMode函數代碼示例

本文整理匯總了TypeScript中angular2/core.enableProdMode函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript enableProdMode函數的具體用法?TypeScript enableProdMode怎麽用?TypeScript enableProdMode使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了enableProdMode函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: enableProdMode

// Angular 2
import 'angular2/core';

import {enableProdMode} from 'angular2/core';
enableProdMode();

// For vendors for example jQuery, Lodash, angular2-jwt import them here
// Also see src/typings.d.ts as you also need to run `typings install x` where `x` is your module
開發者ID:IvanRave,項目名稱:angular2example,代碼行數:8,代碼來源:vendor-ang.ts

示例2: function

module.exports = function(ROOT) {

  var universalPath = `${ROOT}/dist/examples/app/universal`;

  var appPage = require(`${universalPath}/test_page/app`);
  var todoApp = require(`${universalPath}/todo/app`);
  var routerApp = require(`${universalPath}/test_router/app`);

  var {enableProdMode, provide} = require('angular2/core');
  var {ROUTER_PROVIDERS, APP_BASE_HREF} = require('angular2/router');

  enableProdMode();

  var {
    HTTP_PROVIDERS,
    SERVER_LOCATION_PROVIDERS,
    REQUEST_URL,
    PRIME_CACHE,
    queryParamsToBoolean
  } = require('angular2-universal');

  function static(path, route) {
    // console.log(`${ROOT + route}`)
    return {
      method: 'GET',
      path,
      handler: {
        directory: {
          path: `${ROOT + route}`
        }
      }
    };
  }

  function ngRouter(request, reply) {
    let baseUrl = '/examples/router';
    let url = request.originalUrl.replace(baseUrl, '') || '/';
    let queryParams = queryParamsToBoolean(request.query);

    let options = Object.assign(queryParams, {
      // client url for systemjs
      buildClientScripts: true,
      componentUrl: 'examples/app/universal/test_router/browser',
      // ensure that we test only server routes
      client: false,

      directives: [routerApp.App],
      providers: [
        // HTTP_PROVIDERS,
        provide(APP_BASE_HREF, { useValue: baseUrl }),
        provide(REQUEST_URL, { useValue: url }),
        ROUTER_PROVIDERS,
        SERVER_LOCATION_PROVIDERS,
      ],
      data: {},

      preboot: queryParams.preboot === false ? null : true

    });

    reply.view('app/universal/test_router/index', options);
  }

  function get(path, route) {
    return {
      method: 'GET',
      path,
      handler: route
    };
  }

  var router: IHapiRoute[] = [{
    method: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
    path: '/{param*}',
    handler: (request, reply) => {
      reply({
        'route': 'Sorry this page does not exist!'
      });
    }
  }, {
    method: 'GET',
    path: '/',
    handler: (request, reply) => {
      let queryParams = queryParamsToBoolean(request.query);
      let options = Object.assign(queryParams, {
        // client url for systemjs
        buildClientScripts: true,
        componentUrl: 'examples/app/universal/test_page/browser',

        directives: [appPage.App],
        providers: [
          // HTTP_PROVIDERS,
          // SERVER_LOCATION_PROVIDERS,
          // provide(BASE_URL, {useExisting: req.originalUrl}),
          // provide(PRIME_CACHE, {useExisting: true})
        ],
        data: {},

        preboot: queryParams.preboot === false ? null : {
          start: true,
//.........這裏部分代碼省略.........
開發者ID:Pishtiko,項目名稱:universal,代碼行數:101,代碼來源:routes.ts

示例3: provide

import {provide, enableProdMode} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
import {ROUTER_PROVIDERS, APP_BASE_HREF} from 'angular2/router';
import {AppComponent} from './app/components/app.component';
import 'rxjs/Rx';

if ('<%= ENV %>' === 'prod') { enableProdMode(); }

bootstrap(AppComponent, [
    ROUTER_PROVIDERS,
    provide(APP_BASE_HREF, { useValue: '<%= APP_BASE %>' })
]);

window.addEventListener('dragover',function(e){
    e.preventDefault();
},false);
window.addEventListener('drop',function(e){
    e.preventDefault();
},false);
window.addEventListener('dragend',function(e){
    e.preventDefault();
},false);

// In order to start the Service Worker located at "./sw.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) {
//   (<any>navigator).serviceWorker.register('./sw.js').then(function(registration) {
//     console.log('ServiceWorker registration successful with scope: ',    registration.scope);
//   }).catch(function(err) {
//     console.log('ServiceWorker registration failed: ', err);
開發者ID:Gerardo8,項目名稱:lc-client,代碼行數:31,代碼來源:main.ts

示例4:

/*
 * Providers provided by Angular
 */
import * as ngCore from 'angular2/core';
import * as browser from 'angular2/platform/browser';
import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from 'angular2/router';
import {HTTP_PROVIDERS} from 'angular2/http';

/*
 * App Environment Providers
 * providers that only live in certain environment
 */
const ENV_PROVIDERS = [];

if ('production' === process.env.ENV) {
    ngCore.enableProdMode();
    ENV_PROVIDERS.push(browser.ELEMENT_PROBE_PROVIDERS_PROD_MODE);
} else {
    ENV_PROVIDERS.push(browser.ELEMENT_PROBE_PROVIDERS);
}

/*
 * App Component
 * our top level component that holds all of our components
 */
import {App} from './app/app';

/*
 * Bootstrap our Angular app with a top level component `App` and inject
 * our Services and Providers into Angular's dependency injection
 */
開發者ID:xgueret,項目名稱:ng2-mean-webpack,代碼行數:31,代碼來源:main.ts

示例5: provide

import {provide, enableProdMode} from "angular2/core";
import {bootstrap} from "angular2/platform/browser";
// import {ROUTER_PROVIDERS, APP_BASE_HREF } from "angular2/router";
import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from "angular2/router";
// import {AppComponent} from "./app/components/app.component";
import {AppCmp} from "./layout/base/components/app";
// // test to add external dependency
// import {Http, HTTP_PROVIDERS} from "angular2/http";
// import {AuthHttp, AuthConfig} from "angular2-jwt";
// dnd ot test

if ("<%= ENV %>" === "prod") { enableProdMode(); }

bootstrap(AppCmp, [
  ROUTER_PROVIDERS,
  provide(LocationStrategy, { useClass: HashLocationStrategy })
]);

/*
bootstrap(AppComponent, [
  ROUTER_PROVIDERS, // remove HTTP_PROVIDERS, // add to test the addition of extenrnal dependency
  provide(APP_BASE_HREF, { useValue: "<%= APP_BASE %>" }), // note APP_BASE is not correct
  // provide(AuthHttp, { //add to test the addition of external dependency
  //   useFactory: (http: Http) => {
  //     return new AuthHttp(new AuthConfig(), http);
  //   },
  //   deps: [Http]
  // }),
]);

*/
開發者ID:wuyingki,項目名稱:angular2-seed,代碼行數:31,代碼來源:main.ts

示例6: function

module.exports = function(ROOT) {
  var router = Router();

  var appPage = require('../../universal/test_page/app');
  var todoApp = require('../../universal/todo/app');
  var routerApp = require('../../universal/test_router/app');

  var {enableProdMode, provide} = require('angular2/core');
  var {ROUTER_PROVIDERS, APP_BASE_HREF} = require('angular2/router');

  enableProdMode();

  var {
    NODE_HTTP_PROVIDERS,
    NODE_LOCATION_PROVIDERS,
    NODE_PRELOAD_CACHE_HTTP_PROVIDERS,
    REQUEST_URL,
    PRIME_CACHE,
    BASE_URL,
    queryParamsToBoolean
  } = require('angular2-universal-preview');
  // require('angular2-universal')

  router
    .route('/')
    .get(function ngApp(req, res) {
      let queryParams = queryParamsToBoolean(req.query);
      let options = Object.assign(queryParams, {
        // client url for systemjs
        buildClientScripts: true,
        componentUrl: 'examples/src/universal/test_page/browser',

        directives: [appPage.App, appPage.MyApp],
        providers: [
          NODE_LOCATION_PROVIDERS,
          provide(REQUEST_URL, {useValue: req.originalUrl}),
          provide(APP_BASE_HREF, {useValue: '/'}),

          provide(BASE_URL, {useExisting: req.originalUrl}),
          provide(PRIME_CACHE, {useExisting: true}),

          // NODE_HTTP_PROVIDERS,
          NODE_PRELOAD_CACHE_HTTP_PROVIDERS,
        ],
        data: {},

        precache: true,

        preboot: queryParams.preboot === false ? null : {
          start:    true,
          freeze:   'spinner',     // show spinner w button click & freeze page
          replay:   'rerender',    // rerender replay strategy
          buffer:   true,          // client app will write to hidden div until bootstrap complete
          debug:    false,
          uglify:   true,
          presets:  ['keyPress', 'buttonPress', 'focus']
        }

      });

      res.render('src/universal/test_page/index', options);

    });

  router
    .route('/examples/todo')
    .get(function ngTodo(req, res) {
      let queryParams = queryParamsToBoolean(req.query);
      let options = Object.assign(queryParams , {
        // client url for systemjs
        buildClientScripts: true,
        componentUrl: 'examples/src/universal/todo/browser',

        directives: [todoApp.TodoApp],
        providers: [
          // NODE_HTTP_PROVIDERS,
          // NODE_LOCATION_PROVIDERS,
          // provide(BASE_URL, {useExisting: req.originalUrl}),
          // provide(PRIME_CACHE, {useExisting: true})
        ],
        data: {},

        preboot: queryParams.preboot === false ? null : {debug: true, uglify: false}

      });

      res.render('src/universal/todo/index', options);

    });

  router
    .route('/examples/falcor_todo')
    .get(function ngTodo(req, res) {
      let queryParams = queryParamsToBoolean(req.query);
      let options = Object.assign(queryParams , {
        // client url for systemjs
        buildClientScripts: true,
        componentUrl: 'examples/src/universal/falcor_todo/client',

        directives: [todoApp.TodoApp],
//.........這裏部分代碼省略.........
開發者ID:bjwyse,項目名稱:universal,代碼行數:101,代碼來源:routes.ts


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