【问题标题】:Jquery inside a angular2 Typescript not workingangular2 Typescript中的Jquery不起作用
【发布时间】:2017-10-10 13:18:31
【问题描述】:

嗨,我在 angular 4 typescript 中使用 jquery。我尝试使用以下两个事件来修复表头。但它不起作用。

 ngOnInit(): void {
    $(document).ready(function() {
        $("#table").tableHeadFixer({"head" : false, "left" : 1}); 
    });

}

 ngAfterViewInit() {
    $(document).ready(function() {
        $("#table").tableHeadFixer({"head" : false, "left" : 1}); 
    });
 }

渲染表格后,如果我去浏览器控制台执行下面的命令

$("#table").tableHeadFixer({"head" : false, "left" : 1});

表头现在被冻结了。

请帮忙。

【问题讨论】:

  • 首先?你为什么使用jquery。永远不要这样做。你想做什么?
  • 我想修复标题和第一行。有没有办法实现这个功能?
  • 你用的是什么网格?
  • 我使用的是简单的 html 表格
  • 因为你调用了好几次

标签: jquery angular typescript angular2-forms


【解决方案1】:

不要像这样在 Angular 中使用 jquery。如果你需要一个好的表库,有很多为 angular2-4 设计的不错的选择:

ngx-datatable - https://swimlane.github.io/ngx-datatable/
ng2-table - https://github.com/valor-software/ng2-table
wijmo - http://wijmo.com/angular2/
ag-Grid - https://www.ag-grid.com/

【讨论】:

  • 这必须是评论
猜你喜欢
  • 1970-01-01
  • 2017-06-30
  • 2016-08-12
  • 2013-12-18
  • 2017-04-02
  • 2017-06-21
  • 1970-01-01
  • 2017-04-10
  • 1970-01-01
相关资源
最近更新 更多