Ng-table: grunt 构建后的排序问题

创建于 2014-03-03  ·  29评论  ·  资料来源: esvit/ng-table

在“grunt build”之后排序将不起作用,我认为是 js-minify 以某种方式破坏了它。 单击标题时没有任何反应。 奇怪的是,其他一切都有效。 有类似问题的人吗?

这是我的指令控制器

controller: ['$scope', '$filter', 'ScoresAPI', 'ngTableParams', function($scope, $filter, ScoresAPI, ngTableParams)
{
    ScoresAPI.getLeagueStandings($scope.leagueId)
        .success(function(data)
        {
            $scope.tableParams = new ngTableParams({
                page: 1,
                count: data.length,
                sorting: false
            }, {
                total: data.length,
                counts: [],
                getData: function($defer, params)
                {
                    var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
                    $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
                }
            });
        });
}]

最有用的评论

就我而言,它不是 jsminify 目标。 但是是 htmlmin 目标。 我将collapseBooleanAttributes更改为 false,它为我解决了这个问题。 这是目标的整个配置:

htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          collapseBooleanAttributes: false,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html', 'views/{,*/}*.html', 'app_components/{,**/}*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    }

所有29条评论

我面临同样的问题。

就我而言,它不是 jsminify 目标。 但是是 htmlmin 目标。 我将collapseBooleanAttributes更改为 false,它为我解决了这个问题。 这是目标的整个配置:

htmlmin: {
      dist: {
        options: {
          collapseWhitespace: true,
          collapseBooleanAttributes: false,
          removeCommentsFromCDATA: true,
          removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>',
          src: ['*.html', 'views/{,*/}*.html', 'app_components/{,**/}*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    }

太好了,这也解决了我的问题。 谢谢!

我今天遇到了这个问题。 这证明是有用的。

虽然,我不相信这个解决方案是否足以考虑关闭问题。 其他一切正常,无需编辑 Gruntfile.js。 我不知道为什么 ng-table 没有。

该修复程序也对我有用。 但这真的应该重新开放。 自述文件中应该提到

该修复程序也对我有用

这对我不起作用。 我使用 bower 并尝试使用上面发布的版本和此更改:
src: ['_.html', 'views/{,_/}_.html', 'bower_components/{,__/}_.html'],

这是我拥有的 html 文件列表。

$ls -la bower_components/**/*.html
-rw-rw-r-- 1 andrei andrei 1585 iun  7  2013 bower_components/es5-shim/tests/index.html
-rw-rw-r-- 1 andrei andrei 1546 iun  7  2013 bower_components/es5-shim/tests/index.min.html

这个修复程序应该如何工作? 根本原因是什么? 我有 AngularJS 版本 1.2.15

谢谢!。

嗯...似乎$templateCache在我的情况下被使用,这就是为什么忽略上面的“*.html”模式

    $templateCache.put('ng-table/header.html', '<tr> <th ng-repeat="column in $columns" ng-class="{ \'sortable\': parse(column.sortable), \'sort-asc\': params.sorting()[parse(column.sortable)]==\'asc\', \'sort-desc\': params.sorting()[parse(column.sortable)]==\'desc\' }" ng-click="sortBy(column, $event)" ng-show="column.show(this)" ng-init="template=column.headerTemplateURL(this)" class="header {{column.class}}"> <div ng-if="!template" ng-show="!template" ng-bind="parse(column.title)"></div> <div ng-if="template" ng-show="template"><div ng-include="template"></div></div> </th> </tr> <tr ng-show="show_filter" class="ng-table-filters"> <th ng-repeat="column in $columns" ng-show="column.show(this)" class="filter"> <div ng-repeat="(name, filter) in column.filter"> <div ng-if="column.filterTemplateURL" ng-show="column.filterTemplateURL"> <div ng-include="column.filterTemplateURL"></div> </div> <div ng-if="!column.filterTemplateURL" ng-show="!column.filterTemplateURL"> <div ng-include="\'ng-table/filters/\' + filter + \'.html\'"></div> </div> </div> </th> </tr>'),

我解决了我的问题。 我用 'data-sortable="'name'"" 替换了 'sortable="'name'"" 并且它有效。 看一下这个:
http://bit.ly/1BgfqTu

@faisalferoz的方法也适用于我们。 对于 htmlmin 目标,将 collapseBooleanAttributes 更改为 false。

再次@esvit这真的应该在自述文件中。 这是一个重要的功能,它打破了标准且非常常见的生产构建步骤

@andreicristianpetcu的方法也对我们

你是我的英雄,如果我没有找到这个解决方案,我相信我会在这个解决方案上度过余下的夜晚。

谢谢你!!! 这让我发疯

将 Gruntfile 中的collapseBooleanAttributes更改为 false 仍然可以解决此问题 - 感谢您找到它。

+1 @faisalferoz的解决方法。

今天遇到了这个问题。

没有改变 grunt 文件collapseBooleanAttributes: true

这对它进行了排序: sortable => data-sortable

我通过在 Gruntfile 的htmlmin.dist.options中将collapseBooleanAttributes:更改false解决了这个问题

我实际上必须做两件事......将collapseBooleanAttributes:更改false并将代码从<td data-title="'App score'" sortable="'gender'" >{{content.gender}}</td>更改<td sortable="'gender'" data-title="'App score'" >{{content.gender}}</td>单独使用数据排序没有为我修好...

@Jony-Y 这很奇怪。 所以你必须改变在<td>元素中指定 ngTable 属性的顺序?

太好了,这也解决了我的问题。 谢谢!

我将collapseBooleanAttributes: true更改false ,排序可以工作,谢谢

两种解决方案都对我有用。
但是,我也遇到了 CSS 问题(请参阅未排序列上的 2 个向上箭头):
ng-table-css-min

设置以下选项修复了问题:

        cssmin: {
            options: {
                advanced: false
            }
        },


@andreicristianpetcu +1 它也对我

我很高兴它起作用了:D

改变 collapseBooleanAttributes 解决了我的问题,谢谢

使用 data-sortable 对我有用。

更改为 grunt 文件 collapseBooleanAttributes: true 使其在一秒钟内再次工作。

这根本没有帮助我:可排序 => 数据可排序

thx 的提示家伙...

htmlmin

为我解决了。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

richtmat picture richtmat  ·  7评论

Nagendra1402 picture Nagendra1402  ·  3评论

ghost picture ghost  ·  30评论

andreicristianpetcu picture andreicristianpetcu  ·  6评论

raul1991 picture raul1991  ·  6评论