【问题标题】:uncaught (in promise): Error: Cannot match any routes. URL Segment: application未捕获(承诺):错误:无法匹配任何路由。 URL 段:应用程序
【发布时间】:2020-07-27 16:44:48
【问题描述】:

我对 Angular 很陌生。我刚刚用 Angular 创建了一个小应用程序,这个应用程序的后端是 .net core API。我可以在本地主机上运行应用程序而没有任何问题。我在开发服务器上的 IIS 上发布了应用程序。我可以通过在本地计算机上键入 URL 来访问应用程序。当我运行应用程序时。我收到以下错误:

我的代码非常简单,点击按钮,我将一些日期参数传递给我的 API。下面是我的 HTML 代码:

  <button class="appBtn lineButton" (click) = "LoadData()" >
    Start Loading

  </button>

下面是我的 .ts 文件代码:

 LoadData() {

   let  startDate = new Date(this.projectform.value.startDate);
   let endDate = new Date(this.projectform.value.endDate);


           this.service.UploadRecLoadData(this.RecLoadData).subscribe((tempdata) => {

           });

       }


     }

我的服务只是调用 api:

UploadRecLoadData(recLoaddata: RecLoadDataTypeModel){

 return  this.http.get<string>(ROOT_URL + '/' + recLoaddata.startDate +'/' + recLoaddata.endDate , {responseType: 'text' as 'json'});
}

我的 app-routing.module.ts 中没有任何代码。下面是它附带的默认代码。

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';


const routes: Routes = [];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }

我们将不胜感激。

【问题讨论】:

    标签: angular asp.net-core-webapi


    【解决方案1】:

    您的问题不在您提供的代码中。您在其他地方编写了错误的路由代码。你的问题是这样的: Error: Cannot match any routes. URL Segment: - Angular 2

    【讨论】:

    • 我提供了上面的 app-routing.module.ts 文件,我没有在其中编写任何代码。我在哪里可以找到错误的路由代码。除了上面显示的文件之外,我没有对任何其他文件进行更改
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-21
    • 2019-10-14
    • 2020-11-17
    • 1970-01-01
    • 2018-08-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多