angular - 仅在 jhipster 将 webpack 服务器热重载到浏览器控制台时获取 Angular 错误,而不是在其他编译中
问题描述
我有一个根据 jHipster 指令https://www.jhipster.tech/development/配置的调试开发设置,带有代理 webpack 服务器和 broswersink。服务器端工作正常,静态文件从中提取得很好,并且可以在localhost:9000
和上请求,但在 browsersynk 下的浏览器选项卡上调用或localhost:9060
时,不能请求角度应用程序本身。我在浏览器控制台中向我展示了这样的错误:localhost:9000/
localhost:9000/api
Error: Invalid configuration of route 'teacher/class/:id'. One of the following must be provided: component, redirectTo, children or loadChildren
at validateNode (router.js?6580:607)
at validateConfig (router.js?6580:577)
at validateNode (router.js?6580:623)
at validateConfig (router.js?6580:577)
at Router.resetConfig (router.js?6580:4111)
at new Router (router.js?6580:3779)
at setupRouter (router.js?6580:5591)
at _callFactory (core.js?09c9:18520)
at _createProviderInstance (core.js?09c9:18466)
at initNgModule (core.js?09c9:18396)
而且它并不指向在同一个文件中配置的几乎相同的路由。我不知道这条特定路线有什么问题。
在一个地方,我有几条配置如下的路线:
import { Route, Routes } from '@angular/router';
import { CreateKindergartenclassComponent } from 'app/businesslogic';
import { DetailKindergartenclassComponent } from 'app/businesslogic';
import { ListKindergartenclassComponent } from 'app/businesslogic';
import { SelectKindergartenclassComponent } from 'app/businesslogic';
import { UserRouteAccessService } from 'app/core';
import { KindergartenClassResolve } from 'app/entities/kindergarten-class';
import { CommentResolve } from 'app/entities/comment';
export const createKindergartenclassRoute: Route = {
path: 'teacher/class/create',
component: CreateKindergartenclassComponent,
data: {
authorities: ['ROLE_TEACHER_PAID'],
pageTitle: 'businesslogic.create.kindergartenclass.title'
},
canActivate: [UserRouteAccessService]
};
export const detailKindergartenclassRouteChild: Route = {
path: 'child/class/:id',
component: DetailKindergartenclassComponent,
data: {
authorities: ['ROLE_CHILD_PAID'],
pageTitle: 'businesslogic.kindergartenclass.title'
},
resolve: {
kindergartenClass: KindergartenClassResolve
},
canActivate: [UserRouteAccessService]
};
export const detailKindergartenclassRouteTeacher: Route = {
path: 'teacher/class/:id',
component: DetailKindergartenclassComponent,
data: {
authorities: ['ROLE_TEACHER_PAID'],
pageTitle: 'businesslogic.kindergartenclass.title'
},
resolve: {
kindergartenClass: KindergartenClassResolve
},
canActivate: [UserRouteAccessService]
};
export const listKindergartenclassRoute: Route = {
path: 'teacher/classes',
component: ListKindergartenclassComponent,
data: {
authorities: ['ROLE_TEACHER_PAID'],
pageTitle: 'businesslogic.list.kindergartenclass.title'
},
resolve: {
kindergartenClass: KindergartenClassResolve
},
canActivate: [UserRouteAccessService]
};
export const listKindergartenclassRouteChild: Route = {
path: 'child/classes',
component: ListKindergartenclassComponent,
data: {
authorities: ['ROLE_CHILD_PAID'],
pageTitle: 'businesslogic.list.kindergartenclass.title'
},
resolve: {
kindergartenClass: KindergartenClassResolve
},
canActivate: [UserRouteAccessService]
};
export const selectKindergartenclassRoute: Route = {
path: 'child/select',
component: SelectKindergartenclassComponent,
data: {
authorities: ['ROLE_CHILD_PAID'],
pageTitle: 'businesslogic.list.kindergartenclass.title'
},
resolve: {
kindergartenClass: KindergartenClassResolve
},
canActivate: [UserRouteAccessService]
};
export const listKindergartenclassCommentPopupRoute: Route = {
path: 'teacher/classes/:id/delete',
component: ListKindergartenclassComponent,
resolve: {
comment: CommentResolve
},
data: {
authorities: ['ROLE_USER', 'ROLE_TEACHER_PAID'],
pageTitle: 'mentalApp.comment.home.title'
},
canActivate: [UserRouteAccessService]
};
export const listKindergartenclassCommentPopupRouteChild: Route = {
path: 'child/classes/:id/delete',
component: ListKindergartenclassComponent,
resolve: {
comment: CommentResolve
},
data: {
authorities: ['ROLE_USER', 'ROLE_CHILD_PAID'],
pageTitle: 'mentalApp.comment.home.title'
},
canActivate: [UserRouteAccessService]
};
解决方案
*.route.ts
我仍然不清楚为什么,但是在我将大代码分成几个之后,一切都开始在 browsersync 中工作:
import { Route, Routes } from '@angular/router';
import {
CreateKindergartenclassComponent,
DetailKindergartenclassComponent,
ListKindergartenclassComponent,
SelectKindergartenclassComponent
} from 'app/businesslogic';
import { UserRouteAccessService } from 'app/core';
import { KindergartenClassResolve } from 'app/entities/kindergarten-class';
import { CommentResolve } from 'app/entities/comment';
export const createKindergartenclassRoute: Route = {
path: 'teacher/class/create',
component: CreateKindergartenclassComponent,
data: {
authorities: ['ROLE_TEACHER_PAID'],
pageTitle: 'businesslogic.create.kindergartenclass.title'
},
canActivate: [UserRouteAccessService]
};
和
import { Route, Routes } from '@angular/router';
import {
CreateKindergartenclassComponent,
DetailKindergartenclassComponent,
ListKindergartenclassComponent,
SelectKindergartenclassComponent
} from 'app/businesslogic';
import { UserRouteAccessService } from 'app/core';
import { KindergartenClassResolve } from 'app/entities/kindergarten-class';
import { CommentResolve } from 'app/entities/comment';
export const listKindergartenclassCommentPopupRoute: Route = {
path: 'teacher/classes/:id/delete',
component: ListKindergartenclassComponent,
resolve: {
comment: CommentResolve
},
data: {
authorities: ['ROLE_USER', 'ROLE_TEACHER_PAID'],
pageTitle: 'mentalApp.comment.home.title'
},
canActivate: [UserRouteAccessService]
};
export const listKindergartenclassCommentPopupRouteChild: Route = {
path: 'child/classes/:id/delete',
component: ListKindergartenclassComponent,
resolve: {
comment: CommentResolve
},
data: {
authorities: ['ROLE_USER', 'ROLE_CHILD_PAID'],
pageTitle: 'mentalApp.comment.home.title'
},
canActivate: [UserRouteAccessService]
};
和
import { Route, Routes } from '@angular/router';
import {
CreateKindergartenclassComponent,
DetailKindergartenclassComponent,
ListKindergartenclassComponent,
SelectKindergartenclassComponent
} from 'app/businesslogic';
import { UserRouteAccessService } from 'app/core';
import { KindergartenClassResolve } from 'app/entities/kindergarten-class';
import { CommentResolve } from 'app/entities/comment';
export const detailKindergartenclassRoute: Route = {
path: 'teacher/class/:id',
component: DetailKindergartenclassComponent,
data: {
authorities: ['ROLE_TEACHER_PAID'],
pageTitle: 'businesslogic.kindergartenclass.title'
},
resolve: {
kindergartenClass: KindergartenClassResolve
},
canActivate: [UserRouteAccessService]
};
export const detailKindergartenclassRouteChild: Route = {
path: 'child/class/:id',
component: DetailKindergartenclassComponent,
data: {
authorities: ['ROLE_CHILD_PAID'],
pageTitle: 'businesslogic.kindergartenclass.title'
},
resolve: {
kindergartenClass: KindergartenClassResolve
},
canActivate: [UserRouteAccessService]
};
和
import { Route, Routes } from '@angular/router';
import {
CreateKindergartenclassComponent,
DetailKindergartenclassComponent,
ListKindergartenclassComponent,
SelectKindergartenclassComponent
} from 'app/businesslogic';
import { UserRouteAccessService } from 'app/core';
import { KindergartenClassResolve } from 'app/entities/kindergarten-class';
import { CommentResolve } from 'app/entities/comment';
export const listKindergartenclassRoute: Route = {
path: 'teacher/classes',
component: ListKindergartenclassComponent,
data: {
authorities: ['ROLE_TEACHER_PAID'],
pageTitle: 'businesslogic.list.kindergartenclass.title'
},
resolve: {
kindergartenClass: KindergartenClassResolve
},
canActivate: [UserRouteAccessService]
};
export const listKindergartenclassRouteChild: Route = {
path: 'child/classes',
component: ListKindergartenclassComponent,
data: {
authorities: ['ROLE_CHILD_PAID'],
pageTitle: 'businesslogic.list.kindergartenclass.title'
},
resolve: {
kindergartenClass: KindergartenClassResolve
},
canActivate: [UserRouteAccessService]
};
和
import { Route, Routes } from '@angular/router';
import {
CreateKindergartenclassComponent,
DetailKindergartenclassComponent,
ListKindergartenclassComponent,
SelectKindergartenclassComponent
} from 'app/businesslogic';
import { UserRouteAccessService } from 'app/core';
import { KindergartenClassResolve } from 'app/entities/kindergarten-class';
import { CommentResolve } from 'app/entities/comment';
export const selectKindergartenclassRoute: Route = {
path: 'child/select',
component: SelectKindergartenclassComponent,
data: {
authorities: ['ROLE_CHILD_PAID'],
pageTitle: 'businesslogic.list.kindergartenclass.title'
},
resolve: {
kindergartenClass: KindergartenClassResolve
},
canActivate: [UserRouteAccessService]
};
对我来说仍然是 Angular 魔法,但我仍然不知道是什么特殊的分裂导致了这个问题。
推荐阅读
- r - 使用 Sys.setenv() 从 Shiny 模块设置 R 环境变量
- android - 检测是否可以请求或永久拒绝许可
- scala - 数据框:按列名列表分组
- java - 构建测试失败,将测试标记为非强制性
- c++ - 在类中使用映射并通过其他类的 get() 和 set() 函数访问值
- javascript - Canvas JS 图表中的渲染数据
- amazon-web-services - 如何读取 Kinesis Data Stream 中最旧的未处理记录
- dart - 使用 ListView 项内的嵌套列和行滚动卡顿
- php - php 文件有时会导致 500 内部服务器错误
- css - 动态改变颜色 css