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


TypeScript router.provideRouter函數代碼示例

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


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

示例1: function

export default function (params: aspnet.BootFuncParams): Promise<{ html: string, globals?: any }> {
  const serverBindings = [
    ngCore.provide(BASE_URL, { useValue: '/' }),
    ngCore.provide(ORIGIN_URL, { useValue: params.origin }),
    ngCore.provide(REQUEST_URL, { useValue: params.url }),
    ...ngUniversal.NODE_PLATFORM_PIPES,
    ...ngUniversal.NODE_ROUTER_PROVIDERS,
    ...ngUniversal.NODE_HTTP_PROVIDERS,
    ...provideRouter(routes)
  ];

  let boot = ngUniversal.bootloader({
    directives: [App],
    componentProviders: serverBindings,
    async: true,
    preboot: false,
    // TODO: Render just the <app> component instead of wrapping it inside an extra HTML document
    // Waiting on https://github.com/angular/universal/issues/347
    template: '<!DOCTYPE html>\n<html><head></head><body><app></app></body></html>'
  })

  return boot.serializeApplication().then(html => {
    boot.dispose();
    return { html };
  });
}
開發者ID:laskoviymishka,項目名稱:Unicorn.Cms,代碼行數:26,代碼來源:boot-server.ts

示例2: main

export function main(initialHmrState?: any): Promise<any> {

  return bootstrap(App, [
    ...PROVIDERS,
    ...ENV_PROVIDERS,
    ...DIRECTIVES,
    ...PIPES,
    ...APP_PROVIDERS,
    provideRouter(routes, PathLocationStrategy)
  ])
  .catch(err => console.error(err));

}
開發者ID:MichaelFrohberg,項目名稱:michaelfrohberg.github.io,代碼行數:13,代碼來源:main.browser.ts

示例3: main

export function main(): Promise<any> {

  return bootstrap(App, [
    ...PROVIDERS,
    ...ENV_PROVIDERS,
    ...DIRECTIVES,
    ...PIPES,
    ...AUTH_PROVIDERS,
    provideRouter(routes),
    AuthGuard
  ])
    .catch(err => console.error(err));

}
開發者ID:danielsuter,項目名稱:ng2-camp,代碼行數:14,代碼來源:main.browser.ts

示例4: main

export function main(initialHmrState?: any): Promise<any> {

  return bootstrap(App, [
   ...HTTP_PROVIDERS,
    ...ENV_PROVIDERS,
    ...PROVIDERS,
    ...DIRECTIVES,
    ...PIPES,
    ...APP_PROVIDERS,  
    provideStore(todos,initialState),
    provideRouter(routes),
    installSagaMiddleware(...my_sagas)

  ])
  .catch(err => console.error(err));

}
開發者ID:JamesUlph,項目名稱:ng2-start,代碼行數:17,代碼來源:main.browser.ts

示例5: bootstrap

import {bootstrap}    from '@angular/platform-browser-dynamic'
import { provideRouter, Routes } from '@ngrx/router';
import { LocationStrategy,HashLocationStrategy } from '@angular/common';
import { provide } from '@angular/core';
import {provideStore} from '@ngrx/store';

import {AppComponent} from './components/app.component'
import {HelpComponent} from './components/help/help.component'
import {AboutComponent} from './components/about/about.component'
import {CounterComponent} from './components/counter/counter.component.ts'

import {counter} from './reducers/counter';



const routes: Routes = [
	{ path: '/', component: AboutComponent },
	{ path: '/about', component: AboutComponent },
	{ path: '/help', component: HelpComponent },
	{ path: '/cnt', component:CounterComponent}
]

bootstrap(AppComponent, [
	provideRouter(routes),
	provide(LocationStrategy, { useClass: HashLocationStrategy }),
	provideStore({ counter }, { counter: 0 })
]);
// bootstrap(AppComponent, [
// 	provideRouter(routes)
// ]);
開發者ID:mckennatim,項目名稱:ng2-ts-webpack,代碼行數:30,代碼來源:boot.ts

示例6: runEffects

   * with output of relevant (registered as effects) actions being
   * dispatched into your application store. Any side-effects in
   * your application should be registered as effects.
   *
   * Source: https://github.com/ngrx/effects/blob/master/lib/run-effects.ts#L8-L20
   */
  runEffects(effects),

  /**
   * provideRouter sets up all of the providers for @ngrx/router. It accepts
   * an array of routes and a location strategy. By default, it will use
   * `PathLocationStrategy`.
   *
   * Source: https://github.com/ngrx/router/blob/master/lib/index.ts#L44-L51
   */
  provideRouter(routes, HashLocationStrategy),

  /**
   * connectRouterToStore configures additional providers that synchronize
   * router state with @ngrx/store. This lets you debug router state using
   * ngrx/store and to change the location by dispatching actions.
   */
  connectRouterToStore(),

  /**
   * provideDB sets up @ngrx/db with the provided schema and makes the Database
   * service everywhere.
   */
  provideDB(schema),

  /**
開發者ID:bkinsey808,項目名稱:ngrx-graphql-experiment,代碼行數:31,代碼來源:main.browser.ts

示例7: bootstrap

// Import the core angular services.
import { bootstrap } from "@angular/platform-browser-dynamic";

// Import the application components and services.
import { AppComponent } from "./app_component";

import {provideRouter} from '@ngrx/router';
import {routes} from './routes';

bootstrap( AppComponent , [provideRouter(routes)]);
開發者ID:tiagoroldao,項目名稱:angular2-tests,代碼行數:10,代碼來源:main.ts

示例8: bootstrap

import {bootstrap} from '@angular/platform-browser-dynamic';
import {HTTP_PROVIDERS} from '@angular/http';
import {provideRouter} from '@ngrx/router';
import {provideStore} from '@ngrx/store';
import {AppComponent} from './app.component';
import {routesConfig} from './routes.config';
import {ApiService} from './common/api.service';
import {locations} from './common/reducers/locations';
import {issues} from './common/reducers/issues';
import {customers} from './common/reducers/customers';

bootstrap(AppComponent, [
    HTTP_PROVIDERS,
    ApiService,
    provideStore({locations, issues, customers}),
    provideRouter(routesConfig)
]);
開發者ID:flauc,項目名稱:udacityCorporateDashboard,代碼行數:17,代碼來源:main.ts

示例9: bootstrap

import 'zone.js/dist/zone';
import 'reflect-metadata';

import { enableProdMode } from '@angular/core';
import { bootstrap } from '@angular/platform-browser-dynamic';
import { disableDeprecatedForms, provideForms } from '@angular/forms';
import { provideRouter, HashLocationStrategy, PathLocationStrategy } from '@ngrx/router';

import { AppComponent, routes } from './app/app.component';
import { Store } from './store/store';    


// if (process && process.env.ENV === 'production') {
//   enableProdMode();
// }

bootstrap(AppComponent, [
  // provideRouter(routes, HashLocationStrategy),
  provideRouter(routes, PathLocationStrategy),
  Store,
  disableDeprecatedForms(),
  provideForms()
]);
開發者ID:ovrmrw,項目名稱:jspm-angular2-sample,代碼行數:23,代碼來源:boot.ts

示例10: bootstrap

// Import the application routes.
import { appRoutes } from "./app.routes";
import { AutofocusDirective } from "~/shared/directives/index";
import { LoadingIndicatorComponent } from "~/shared/directives/index";
import { ShowBlockDirective } from "~/shared/directives/index";

bootstrap(
	AppComponent,
	[
		// Make the router directives available to the entire application.
		// {
		// 	provide: PLATFORM_DIRECTIVES,
		// 	useValue: ROUTER_DIRECTIVES,
		// 	multi: true
		// },
		provideRouter( appRoutes ),

		// By default, the ngRx Router uses the PathLocationStrategy which uses the HTML5 
		// history.pushState() to change the URL without going back to the browser. This
		// strategy requires that the server knows how to handle these URLs when / if the
		// browser is refreshed or deep-linked. Since I am running this demo in GitHub
		// on gh-pages, there is no server-side rendering. As such, I have to use the 
		// HashLocationStrategy, which puts the active URL behind the /#/. Otherwise, the
		// demo would only work on the first load and break on most browser refreshes.
		{
			provide: LocationStrategy,
			useClass: HashLocationStrategy
		},

		// Add some globally-available directives.
		{
開發者ID:bennadel,項目名稱:JavaScript-Demos,代碼行數:31,代碼來源:main.ts


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