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


TypeScript angular2-universal.provide函數代碼示例

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


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

示例1: ngApp

function ngApp(req, res) {
  let baseUrl = '/';
  let url = req.originalUrl || '/';

  let config: ExpressEngineConfig = {
    // directives: [ Noop ],
    directives: [ App ],
    platformProviders: [
      provide(ORIGIN_URL, {useValue: 'http://localhost:3000'}),
      provide(BASE_URL, {useValue: baseUrl}),
    ],
    providers: [
      provide(REQUEST_URL, {useValue: url}),
      ...NODE_ROUTER_PROVIDERS,
      ...NODE_HTTP_PROVIDERS,
      ...NODE_STORE_PROVIDERS
    ],
    async: true,
    preboot: true
  };

  res.render('index', config);
}
開發者ID:Erbolking,項目名稱:ng-conf-2016-universal-patterns,代碼行數:23,代碼來源:server.ts

示例2: ngApp

function ngApp(req: express.Request, res) {
  let baseUrl = '/';
  let url = req.originalUrl || '/';
  res.render('index', {
    directives: [ App, HtmlHead, ServerOnlyApp],
    platformProviders: [
      provide(ORIGIN_URL, {useValue: 'http://localhost:3000'}),
      provide(BASE_URL, {useValue: baseUrl}),
    ],
    providers: [
      provide(REQUEST_URL, {useValue: url}),
      NODE_ROUTER_PROVIDERS,
      NODE_HTTP_PROVIDERS,
    ],
    async: true,
    preboot: false,
    // preboot: {
    //   appRoot: 'app',
    //   uglify: false,
    //   debug: true
    // }
  });
}
開發者ID:Quramy,項目名稱:universal-starter,代碼行數:23,代碼來源:server.ts

示例3: ngApp

function ngApp(req: any, res: any) {
    let baseUrl = '/';
    let url = req.originalUrl || '/';

    let config: ExpressEngineConfig = {
        directives: [App],

        platformProviders: [
            provide(ORIGIN_URL, { useValue: `http://localhost:${port}` }),
            provide(BASE_URL, { useValue: baseUrl }),
        ],
        providers: [
            provide(REQUEST_URL, { useValue: url }),
            NODE_ROUTER_PROVIDERS,
            NODE_HTTP_PROVIDERS,
        ],
        async: true,
        preboot: { appRoot: 'app' }
    };

    console.log('render index');

    res.render('index', config);
}
開發者ID:SimplyComplexCo,項目名稱:material-universal-test,代碼行數:24,代碼來源:index.ts

示例4: express

    NODE_HTTP_PROVIDERS
} from 'angular2-universal';

let app = express();

import {AppComponent} from '../app/app.component';

app.engine('.html', expressEngine);
app.set('views', __dirname);
app.set('view engine', 'html');

let baseUrl = '/';
let config: ExpressEngineConfig = {
    directives: [ AppComponent ],
    platformProviders: [
        provide(ORIGIN_URL, {useValue: 'http://localhost:3000'}),
        provide(BASE_URL, {useValue: baseUrl}),
    ],
    providers: [
        provide(REQUEST_URL, {useValue: baseUrl}),
        NODE_ROUTER_PROVIDERS,
        NODE_HTTP_PROVIDERS,
    ],
    async: true,
    preboot: false // { appRoot: 'app' } // your top level app component selector
};

// Serve static files
app.use(express.static('.'));

app.use('/', function(req, res){
開發者ID:samlam,項目名稱:helloNg2,代碼行數:31,代碼來源:server.ts

示例5: provide

import { disableDeprecatedForms, provideForms } from '@angular/forms';
import {
  // NODE_HTTP_PROVIDERS,
  // NODE_ROUTER_PROVIDERS
  provide
} from 'angular2-universal';

export const APPLICATION_PROVIDERS = [
  // ...NODE_HTTP_PROVIDERS,
  // ...NODE_ROUTER_PROVIDERS,
  provide(Window, { useValue: {} }),
  disableDeprecatedForms(),
  provideForms()
];

export const PROVIDERS = [
  ...APPLICATION_PROVIDERS
];
開發者ID:narr,項目名稱:narr,代碼行數:18,代碼來源:providers.ts

示例6: Bootloader

  provide,
  enableProdMode,
  expressEngine,
  REQUEST_URL,
  ORIGIN_URL,
  BASE_URL,
  NODE_ROUTER_PROVIDERS,
  NODE_HTTP_PROVIDERS,
  Bootloader
} from 'angular2-universal';

import { App } from '../app';

const bootloader = new Bootloader({
  platformProviders: [
    provide(ORIGIN_URL, { useValue: 'http://localhost:3000' }),
    provide(BASE_URL, { useValue: '/' })
  ],
  async: true,
  preboot: false
});

export function ngApp(req, res) {
  const url = req.originalUrl || '/';

  const APP_CONFIG = {
    template: `
    <!doctype html>
    <html>
      <head>
        <meta charset="utf-8">
開發者ID:drejohnson,項目名稱:universal-angular2-starter,代碼行數:31,代碼來源:app.ts


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