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