Sorting wont work after 'grunt build', I assume it is the js-minify that somehow breaks it. Nothing happens when I click a header. Strange though that everything else works. Anyone with similar problems?
Here's my directive controller
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()));
}
});
});
}]
I am facing the same issue.
In my case it wasn't the jsminify target. But was the htmlmin target. I changed collapseBooleanAttributes
to false and it solved the issue for me. Here is the whole configuration of the target:
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 %>'
}]
}
}
Great, that solved my problem as well. Thanks!
I faced this very issue today. This proved useful.
Although, I'm not convinced if this solution is enough to consider the issue closed. Everything else works all right without editing the Gruntfile.js. Why ng-table does not is beyond my knowledge.
the fix worked for me also. But this should really be reopened. There should be a mention in the readme about
the fix worked for me also
This does not work for me. I use bower and I tried both with the version posted above and with this change:
src: ['_.html', 'views/{,_/}_.html', 'bower_components/{,__/}_.html'],
This is the list of html files that I have.
$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
How is this fix supposed to work? What is the root cause? I have AngularJS version 1.2.15
Thank you!.
Hmmm... it appears that $templateCache
is used im my situation and this is why ignoring the "*.html" pattern above
$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>'),
I solved my issue. I replaced 'sortable="'name'"" with 'data-sortable="'name'"" and it works. Check this out:
http://bit.ly/1BgfqTu
@faisalferoz's approach worked for us too. For the htmlmin target, changing collapseBooleanAttributes to false.
again @esvit this should really be in the readme. this is an important feature that breaks from a standard and quite common production build step
@andreicristianpetcu's approach worked for us too (team is switching to that so we can still reap benefits of gulp-htmlmin's optimizations elsewhere).
You're my hero, had I not found this solution I'm sure I would have spent the remainder of my evening on this one.
THANK YOU!!! This was driving me insane
changing collapseBooleanAttributes
in the Gruntfile to false still fixes this issue - thanks for finding that.
+1 to @faisalferoz's workaround.
Had this issue today.
No change to the grunt file collapseBooleanAttributes: true
This sorted it: sortable
=> data-sortable
I resolved this issue by changing collapseBooleanAttributes:
to false
in Gruntfile's htmlmin.dist.options
I actually had to do two things... change the collapseBooleanAttributes:
to false
and also change the code from <td data-title="'App score'" sortable="'gender'" >{{content.gender}}</td>
to <td sortable="'gender'" data-title="'App score'" >{{content.gender}}</td>
working with data-sorting alone did not fix for me...
@Jony-Y that's odd. So you had to switch the order of how you specified the ngTable attributes in the <td>
elements?
Great, that solved my problem as well. Thanks!
I am change collapseBooleanAttributes: true
to false
, the sorting can work , Thank you
Both solutions worked for me.
However I was having a CSS issue as well (see the 2 up arrows on not sorted columns):
Setting the following option fixed the issue:
cssmin: {
options: {
advanced: false
}
},
@andreicristianpetcu +1 It worked for me too!
I'm glad it worked :D
changing collapseBooleanAttributes solved my problem, thx
Using data-sortable worked for me.
Change to the grunt file collapseBooleanAttributes: true made it work again in a second.
This did not help me at all: sortable => data-sortable
thx for the tips guys...
htmlmin
Solved for me.
Most helpful comment
In my case it wasn't the jsminify target. But was the htmlmin target. I changed
collapseBooleanAttributes
to false and it solved the issue for me. Here is the whole configuration of the target: