本文整理汇总了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);
}
示例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
// }
});
}
示例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);
}
示例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){
示例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
];
示例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">