我是Angular假人,我使用的jhipster与Spring Boot v2.0.3.RELEASE,Spring v5.0.7.RELEASE一起运行。在我的项目中,我有两个实体:Book和Library。 我在首页中包含了图书馆清单表。为此,我使用了:
<jhi-library></jhi-library>
在将LibraryComponent导入到主页ecc之后... 我可以查看库列表,但分页时出错。 生成的网址是:
http://localhost:9000/api/library?page=NaN&size=20&sort=undefined,desc&sort=id
页面参数为空...
我认为问题是由于调用路由链接(“库”)时解析器为JhiResolvePagingParams。所以如果我检查 this.activatedRoute.data为空。
this.routeData = this.activatedRoute.data.subscribe(data => {
this.page = data.pagingParams.page;
this.previousPage = data.pagingParams.page;
this.reverse = data.pagingParams.ascending;
this.predicate = data.pagingParams.predicate;
});
所以...我不知道这是否是包含组件的正确方法... 我试图将书籍包含在图书馆页面中,但出现了相同的错误... 为此,我做到了: -我将book.component.html复制到library.detail.html; -在我的library.component.ts中添加了以下内容:
ngOnInit() {
this.activatedRoute.data.subscribe(({ library }) => {
this.library = library;
});
this.getBooks();
}
getBooks(): void {
const id = +this.activatedRoute.snapshot.params.id;
this.libraryService.getBooks(id).subscribe(
(res: HttpResponse<IBooks[]>) => {
this.covergroups = res.body;
},
(res: HttpErrorResponse) => this.onError(res.message)
);
}
我注意到要分页,我必须打电话:[callback] =“ transition.bind(this)” 但是..如果我对此发表评论,则无法显示分页按钮;如果我不对此发表评论,则会出现此错误:
Cannot read property 'bind' of undefined
有人可以帮助我指出哪种方法正确吗?我的错误在哪里?