Angular 2:路由'home'的配置无效。必须提供以下其中一项:component,redirectTo,children或loadChildren

时间:2017-02-11 10:01:08

标签: angular angular2-routing

我正在尝试在Angular 2中实现路由,这些是我的文件

app.module.ts

id(a) != id(0.0)

app.routes.ts

import {Component, NgModule} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
import {HomeComponent} from "./home.component";
import {RentedHomeComponent} from "./rented-home";
import {TenantComponent} from "./tenant.component";
import {SubTenantComponent} from "./sub-tenant.component";
import {BreadcrumbService} from "./breadcrumb.service";
import {routes, routingProviders} from "./app.routes";
import {RouterModule} from "@angular/router";
import {BreadcrumbComponent} from "./breadcrumb.component";
import {APP_BASE_HREF} from "@angular/common";

@Component({
  selector: 'my-app',
  template: `
    <h1 class="title">This is the landing page and no Breadcrumb here</h1>
    <a routerLink="/rented-home" class="btn btn-md btn-primary">View Customer Detail</a>
   <div class="row">
      <div class="col-md-12">
        <router-outlet></router-outlet>
      </div>
    <div class="main-view">
    </div>`,
})
export class App { }

@NgModule({
  imports: [ BrowserModule, RouterModule, routes ],
  declarations: [ App, HomeComponent, RentedHomeComponent, TenantComponent, SubTenantComponent, BreadcrumbComponent  ],
  providers: [routingProviders, BreadcrumbService,
    { provide: APP_BASE_HREF, useValue: '/' }],
  bootstrap: [ App ]
})
export class AppModule {}

但我得到了 - 未处理的承诺拒绝:路线“家”的配置无效。必须提供以下其中一项:component,redirectTo,children或loadChildren;区域:;任务:Promise.then;价值:

对此有何帮助?

0 个答案:

没有答案