我是angular 6和asp.net核心web api的新手,我正在尝试从valuesController getPatients中获取数据,并将在网格中显示结果但是我收到此错误
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: '**'
Error: Cannot match any routes. URL Segment: '**'
at ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError (router.js:1384)
at CatchSubscriber.selector (router.js:1365)
at CatchSubscriber.push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchSubscriber.error (catchError.js:100)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:132)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:106)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:132)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:106)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:132)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:106)
at TapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/tap.js.TapSubscriber._error (tap.js:108)
at resolvePromise (zone.js:831)
at resolvePromise (zone.js:788)
at zone.js:892
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:3811)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
at drainMicroTaskQueue (zone.js:601)
defaultErrorLogger @ core.js:1673
:44320/api/Values:1 Failed to load resource: net::ERR_CONNECTION_RESET
core.js:1673 ERROR HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: null, ok: false, …}
我的module-routing.ts如下
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router'
import { PatientlistComponent } from './patientlist/patientlist.component';
import { AddpatientComponent } from './addpatient/addpatient.component';
export const routes: Routes = [
//{ path: '', component: PatientlistComponent, pathMatch: 'full' },
{ path: 'patientlist', component: PatientlistComponent },
{ path: 'addpatient', component: AddpatientComponent }
];
@NgModule({
imports: [
CommonModule,
RouterModule.forRoot(routes)
],
exports: [RouterModule],
declarations: []
})
a
export class AppRoutingModule { }
和appModule
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';
import { ReactiveFormsModule } from '@angular/forms'
//import { AppComponent } from './app.component';
import { PatientlistComponent } from './patientlist/patientlist.component';
import { AppRoutingModule } from './/app-routing.module';
import { AddpatientComponent } from './addpatient/addpatient.component';
import { PatientServiceService } from './patient-service.service';
@NgModule({
declarations: [
// AppComponent,
PatientlistComponent,
AddpatientComponent
],
imports: [
BrowserModule,
HttpModule,
HttpClientModule,
AppRoutingModule
],
providers: [PatientServiceService],
//bootstrap: [AppComponent]
bootstrap: [PatientlistComponent]
})
export class AppModule { }
请帮助解决这个问题TIA
您尚未设置正确的默认路径路径
你需要设置
{ path: 'your default path ',
redirectTo: 'redirect url',
pathMatch: 'full',
}
您缺少应用程序默认(/)路由。请添加默认路由,希望它能正常工作。