0
をロードするための第一出口を見つけることができません私のホームページがappcomponentあるように私は私のルートを変更し、そして今、私はこのエラーを取得しています:エラー:(約束で)キャッチされない:エラー:「AppComponent」
Error: Uncaught (in promise): Error: Cannot find primary outlet to load 'AppComponent'
これが何であるかについてのいかなる考え?
マイルート:
import {Routes} from "@angular/router";
import {PatientComponent} from "./patient/patient.component";
import {AppComponent} from "./app.component";
export const routes: Routes = [
{path: '', component: AppComponent},
{path: 'patient/:id', component: PatientComponent},
];
私のアプリのコンポーネントは:
import {Component, OnInit} from '@angular/core';
import {AfdelingService} from './afdeling.service';
import {PatientService} from './patient.service';
import 'rxjs/Rx';
import {Router} from "@angular/router";
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers: [AfdelingService, PatientService]
})
export class AppComponent implements OnInit {
errorMessage: string;
afdeling = [];
constructor(private afdelingService: AfdelingService, private router: Router) {
}
ngOnInit() {
this.getData()
}
goToAfdeling(afdeling) {
console.log(afdeling.afdelingsNaam);
this.router.navigate(["/afdelingen", afdeling.afdelingsNaam]);
}
getData() {
this.afdelingService.getAfdelingen()
.subscribe(
data => {
this.afdeling = data;
console.log(this.afdeling);
}, error => this.errorMessage = <any> error);
}
}
アプリのコンポーネントは、アプリケーションのシェルでなければなりませんし、ルーティング対象ではありません。 – DeborahK
上記のコメントに追加する...あなたは経路の内容を表示するためにルータのアウトレットを定義する必要があります... – Lambo14