angular - 未捕获( promise ): Error: Cannot match any routes. URL 段:应用程序

标签 angular asp.net-core-webapi

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

enter image description here

我的代码非常简单,点击按钮后,我将一些日期参数传递给我的 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 { }

我们将不胜感激任何帮助。

最佳答案

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

关于angular - 未捕获( promise ): Error: Cannot match any routes. URL 段:应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61216447/

相关文章:

swift - HTTP Get API调用总是失败 "NSLocalizedDescription=A server with the specified hostname could not be found"

httpresponse - 使用 API 路由时,未授权时返回 Http Response 401 而不是重定向到登录页面

angular - 将范围数据传递到 Angular2 中的 ng-content

复杂对象的 Angular 自定义输入

angular - 如何检测 ionic 4的 ion-content 成分中的涡旋到达终点?

javascript - 错误 TS2739 : Type '{}' is missing the following properties from type

swagger - 如何在 Swagger 中显示查询参数的 C# 验证属性

c# - 调用 SignalR Hub 不适用于 Asp.Net Core Web API

c# - 带有文件和字典的 AspNetCore3 多部分帖子未按预期工作

javascript - 尝试将 http 响应分配给数据源时出现 Angular 表错误