问题描述
我正在查看 ng-bootstrap的官方文档 ,在他们的一些官方示例中,该代码无法正常工作.我特别是在谈论此和.这使我很难理解代码的工作方式,从而可以按自己的方式实现它.
I am going through the official documentation of ng-bootstrap, in some of their official examples, the code is not working. In particular I am talking about this and this examples, when you open them in stackblitz. This makes it hard for me to understand how the code works so that I can implement it my way.
我见过这个问题,但答案是对于angularjs来说已经过时了.
I have seen this question but the answer is outdated as it is for angularjs.
所以现在我的问题是:
- 我如何实现ng-bootstrap 4表排序,分页和过滤,如下所示这里?给定代码有什么问题,为什么不起作用?
- How can I implement ng-bootstrap 4 table sorting, pagination and filtering as shown here? What is the issue with the given code why is it not working?
一个有效的示例将非常有用,因为它将帮助我了解和理解代码的工作原理.谢谢.
A working example would be great as it would help me see and understand how the code works. Thank you.
推荐答案
我终于有了解决方案.我去他们的github 来检查问题并有人确认确实stackblitz代码有问题,但给出了源代码并提供了解决方法.
I finally have a solution. I went to their github to check the issues and someone confirmed that indeed the stackblitz code has an issue but gave the source code and a work-around.
这是工作代码 带有排序,分页和过滤功能的ng-bootstrap 4表.
Here is the working code of an ng-bootstrap 4 table with sorting, pagination and filtering.
我基本上组织了代码,并添加了原始stackblitz代码中省略的一些内容.
I basically organised the code and added a few things that were omitted in the original stackblitz code.
存在的问题之一是该指令未在AppModule的声明数组中声明.
Among the issues that were there, was that the directive wasn't declared in the declarations' array in AppModule.
这篇关于如何实现ng-bootstrap 4表排序,分页和过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!