本文整理汇总了TypeScript中@angular/router.provideRouter函数的典型用法代码示例。如果您正苦于以下问题:TypeScript provideRouter函数的具体用法?TypeScript provideRouter怎么用?TypeScript provideRouter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了provideRouter函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: bootstrap
import {bootstrap} from '@angular/platform-browser-dynamic'
import { provideRouter, RouterConfig } from '@angular/router';
import {LocationStrategy, HashLocationStrategy} from '@angular/common'
import {provide} from '@angular/core'
import {SimpleRouting} from './app.component'
import ComponentOne from './component-one';
import ComponentTwo from './component-two';
import ComponentThree from './component-three';
/*
@RouteConfig([
{path: '/componentOne', as: 'ComponentOne', useAsDefault: true, component: ComponentOne},
{path: '/componentTwo', as: 'ComponentTwo', useAsDefault: false, component: ComponentTwo},
{path: '/componentThree/:message', as: 'ComponentThree', useAsDefault: false, component: ComponentThree}
])*/
const routes: RouterConfig = [
{path: '/component-one', useAsDefault: true, component: ComponentOne},
{path: '/component-two', useAsDefault: false, component: ComponentTwo},
{path: '/component-three/:message', useAsDefault: false, component: ComponentThree}
]
bootstrap(SimpleRouting, [provideRouter(routes), provide(LocationStrategy, {useClass: HashLocationStrategy})]);
示例2: bootstrap
import { bootstrap } from '@angular/platform-browser-dynamic';
import { provideRouter } from '@angular/router';
import { AppComponent } from './components/app.component';
import { appRoutes } from './components/app.routing';
import { disableDeprecatedForms, provideForms } from '@angular/forms';
import { HTTP_PROVIDERS } from '@angular/http';
import { AUTH_PROVIDERS } from 'angular2-jwt/angular2-jwt';
bootstrap(AppComponent, [
disableDeprecatedForms(), // disable deprecated forms
provideForms(),
provideRouter(appRoutes), // enable new forms module
AUTH_PROVIDERS,
HTTP_PROVIDERS
])
.catch(err => console.log(`Error bootstrapping App ${err}`));
示例3: provideRouter
import { provideRouter, RouterConfig } from '@angular/router';
import { CustomersRoutes } from './customers/customers.routes';
import { CustomerRoutes } from './customer/customer.routes';
export const App_Routes: RouterConfig = [
...CustomersRoutes,
...CustomerRoutes,
{ path: '**', pathMatch:'full', redirectTo: '/customers' } //catch any unfound routes and redirect to home page
];
export const APP_ROUTER_PROVIDERS = [
provideRouter(App_Routes)
];
示例4: provideRouter
import { provideRouter } from '@angular/router';
import { RecipesComponent } from './recipes';
import { ShoppingListComponent } from './shopping-list';
import { RECIPE_ROUTES } from './recipes/recipes.routes';
export const APP_ROUTES_PROVIDERS = [
provideRouter([
{
path: '',
redirectTo: '/recipes',
pathMatch: 'full'
},
{
path: 'recipes',
component: RecipesComponent,
children: RECIPE_ROUTES
},
{
path: 'shopping-list',
component: ShoppingListComponent
}
])
];
示例5: bootstrap
import { HTTP_PROVIDERS } from '@angular/http';
import { bootstrap } from '@angular/platform-browser-dynamic';
import { disableDeprecatedForms, provideForms } from '@angular/forms'
import { EkApplication, EKAppRoutes } from './components/team.components'
import { TeamService } from './services/team.service'
import { provide } from '@angular/core'
import { provideRouter } from '@angular/router'
// import { ROUTER_PROVIDERS } from '@angular/router-deprecated'
import { LocationStrategy, HashLocationStrategy, PathLocationStrategy } from '@angular/common'
import { parent } from './components/form.components'
bootstrap(EkApplication,
[TeamService,
disableDeprecatedForms(),
provideRouter(EKAppRoutes),
provideForms(),// ROUTER_PROVIDERS,
// provide(LocationStrategy, {useClass:HashLocationStrategy}),
HTTP_PROVIDERS])
示例6: enableProdMode
import { bootstrap } from '@angular/platform-browser-dynamic';
import { provideRouter } from '@angular/router';
import { enableProdMode } from '@angular/core';
import { disableDeprecatedForms, provideForms } from '@angular/forms';
import { AppComponent, environment } from './app/';
import { AppRoutes } from './app/app.routes';
if (environment.production) {
enableProdMode();
}
bootstrap(AppComponent, [
provideRouter(AppRoutes),
disableDeprecatedForms(),
provideForms()
]);
示例7:
import {RouterConfig, provideRouter} from "@angular/router";
import {HelloComponent} from "./hello/hello";
import {CHILD_ROUTERS, CHILD_ROUTER_GUARDS} from "./childrouter/childrouter";
import {FORMS_ROUTERS} from "./forms/forms";
const routes: RouterConfig = [
{ path: "hello", component: HelloComponent },
{ path: "", redirectTo: "hello", pathMatch: "full" },
...FORMS_ROUTERS,
...CHILD_ROUTERS,
{ path: "**", redirectTo: "hello" },
];
const APP_ROUTER_PROVIDERS: any[] = [provideRouter(routes), CHILD_ROUTER_GUARDS];
export {
APP_ROUTER_PROVIDERS
};
示例8: provideRouter
import { provideRouter, RouterConfig } from '@angular/router';
import { LoginComponent } from './login/';
import { ChatComponent } from './chat/';
export const Routes: RouterConfig = [
{ path: 'login', component: LoginComponent },
{ path: 'chat', component: ChatComponent },
{ path: '', redirectTo: '/login' }
]
export const APP_ROUTER_PROVIDERS = [
provideRouter(Routes)
];
示例9: enableProdMode
import 'babel-polyfill';
import 'core-js/es6';
import 'core-js/es7/reflect';
import 'ts-helpers';
import '../shims/shims_for_IE';
import 'zone.js/dist/zone';
import { enableProdMode } from '@angular/core';
import { bootstrap } from '@angular/platform-browser-dynamic';
import { RioSampleAppComponent } from './containers/sample-app';
import { provideRouter } from '@angular/router';
import { SAMPLE_APP_ROUTES } from './routes/sample-app';
declare const __PRODUCTION__: boolean;
declare const __TEST__: boolean;
if (__PRODUCTION__) {
enableProdMode();
} else {
require('zone.js/dist/long-stack-trace-zone');
}
if (!__TEST__) {
bootstrap(RioSampleAppComponent, [
provideRouter(SAMPLE_APP_ROUTES),
]);
}
示例10: enableProdMode
import { FIREBASE_PROVIDERS, defaultFirebase} from 'angularfire2';
import {TestAppRoutes} from './app/app.routes'
// import { disableDeprecatedForms, provideForms } from '@angular/forms';
// import { routeConfig } from './app/routerconfigs/router.config';
if (environment.production) {
enableProdMode();
}
bootstrap(AppComponent, [
FIREBASE_PROVIDERS,
// Initialize Firebase app
defaultFirebase({
apiKey: "AIzaSyD-XIYtmEXlQMy4uufzp_Mrxai253u_6fE",
authDomain: "project-3617555751812177585.firebaseapp.com",
databaseURL: "https://project-3617555751812177585.firebaseio.com",
storageBucket: "project-3617555751812177585.appspot.com"
}),
// Initialize router:
// Needs:
// imports for provideRouter here and RouterOutler in app.component.ts
// <router-outlet></router-outlet> tag in app.component.html
// RouteConfig array defined (ex in app.routes.ts)
provideRouter(TestAppRoutes)
// disableDeprecatedForms(),
// provideForms()
])
.catch((err: any) => console.error(err));