[英]Sort a table column where the header has whitspace
I have an angular based table which I would like to sort by one of the columns 我有一个基于角度的表格,我想按其中一列进行排序
If I sort by the column Reference this line works 如果按“参考”列进行排序,则此行有效
<tr ng-repeat="row in documentaryCreditsTable.rows | orderBy:'-Reference'">
However I would like to sort by a column named 'Expiry date' and I'm assuming that since this column has a space I'm getting the following error: 但是,我想按名为“到期日期”的列进行排序,并且我假设由于此列具有空格,因此出现以下错误:
<tr ng-repeat="row in documentaryCreditsTable.rows | orderBy:'-Expiry date'">
Error: [$parse:syntax] Syntax Error: Token 'date' is an unexpected token at column 8 of the expression [Expiry date] starting at [date]. 错误:[$ parse:syntax]语法错误:令牌'date'是从[date]开始的表达式[Expiry date]的第8列上的意外令牌。
Any idea how to work around that as this String is what is presented to the user on the screen and I would like to keep the whitespace. 任何解决该字符串的方法都可以在屏幕上看到,而我想保留空白。
Controller: 控制器:
var sortBy = 'Expiry date';
$scope.predicate = function(val) {
return -val[sortBy];
}
View: 视图:
<tr ng-repeat="row in documentaryCreditsTable.rows | orderBy:predicate">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.