Angular 角度8-无法匹配任何路线。URL段:';javascript:void(0)和#x27;

Angular 角度8-无法匹配任何路线。URL段:';javascript:void(0)和#x27;,angular,angular8,angular-routing,angular-router,Angular,Angular8,Angular Routing,Angular Router,我有一个angular 8应用程序,我在其中使用外部依赖,它在我的应用程序中生成分页表。我只需要将json数据传递给它,它将为我完成其余的工作 因此,分页表生成下一页和上一页的链接。如果我将其悬停,它将显示localhost:4200/javascript:void(0)。据我所知,我的应用程序应该忽略此超链接,因为基础脚本必须具有此超链接的onClick功能 但我还是在犯错误 ERROR Error: Uncaught (in promise): Error: Cannot match any

我有一个angular 8应用程序,我在其中使用外部依赖,它在我的应用程序中生成分页表。我只需要将json数据传递给它,它将为我完成其余的工作

因此,分页表生成下一页和上一页的链接。如果我将其悬停,它将显示
localhost:4200/javascript:void(0)
。据我所知,我的应用程序应该忽略此超链接,因为基础脚本必须具有此超链接的onClick功能

但我还是在犯错误

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'javascript%20:%20void%280%29'
Error: Cannot match any routes. URL Segment: 'javascript%20:%20void%280%29'
    at ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError (router.js:2459)
    at CatchSubscriber.selector (router.js:2440)
    at CatchSubscriber.push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchSubscriber.error (catchError.js:34)
    at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:79)
    at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:59)
    at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:79)
    at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:59)
    at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:79)
    at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:59)
    at ThrowIfEmptySubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:79)
    at resolvePromise (zone.js:852)
    at resolvePromise (zone.js:809)
    at zone.js:913
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Object.onInvokeTask (core.js:26247)
    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)
    at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:502)
    at invokeTask (zone.js:1693)
下面是我的
应用程序路由.module.ts

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AppComponent } from './app.component';


const routes: Routes = [
  {
    path: HEALTH,
    pathMatch: FULL,
    loadChildren: './health/health.module#HealthModule'
  },
  {
    path: EMPTY_STRING,
    resolve: {
      LoggedInDetail: LoggedInDetailResolve
   },
    component: FullPageLayoutComponent,
    children: [
      {
        path: '',
        redirectTo: 'index',
        pathMatch: 'full'
      }
    ]
  },
  {
    path: EMPTY_STRING,
    component: AppComponent,
    children: [
      {
        path: TEMPLATE_ROUTE,
        component: TemplateComponent
      }
    ]
  }

];

@NgModule({
imports: [RouterModule.forRoot(routes, { useHash: true })],
exports: [RouterModule],
  providers: [LoggedInDetailResolve]
})
export class AppRoutingModule { }
请注意,我使用的是基于散列的URL

imports: [RouterModule.forRoot(routes, { useHash: true })],

请从代码中删除路径匹配:FULL

或者您可以使用as路径匹配:“前缀”

路径匹配:'full':在这种情况下,当在localhost:4200(或某些服务器)上启动应用程序时,默认页面将是欢迎屏幕,因为url将是https://localhost:4200/

如果https://localhost:4200/surendra 这将重定向到pageNotFound屏幕,因为路径为“**”通配符


路径匹配:'prefix':如果路由具有{path:'',则重定向到:'initial',路径匹配:'prefix'},现在这将永远不会到达通配符路由,因为每个url都将匹配定义的路径:''。

这对我不起作用。FULL和Prefixhave之间的区别是什么?您已从父对象中删除了路径匹配。让我试试。我尝试了这两个选项,但仍然不起作用。您是否在动态地将HTML添加到DOM中?Angular将尝试清理并删除javascript。听起来你已经将href设置为javascript void,Angular正在清理它,所以它只是一个字符串,这就是为什么它试图将其添加到URL。你能创建stackblitz演示吗?请共享你的分页代码。您的路由有问题,不能使用类似于
javascript:void(0)
的东西!