【发布时间】:2024-04-18 16:40:05
【问题描述】:
我有一个表格单元格,它显示是否有超过 10 条记录。我的分页的一部分。
<td ng-show="totalRecords>10" colspan="5">
<ul uib-pagination style="margin:0;" total-items="totalRecords" ng-model="currentPage" ng-change="pageChanged()"></ul>
</td>
非常简单。但这是疯狂的 - 它在 Chrome 中引发以下错误:
Uncaught Error: Syntax error, unrecognized expression: td[ng-show='totalRecords @ browserLink:37
bc.error @ browserLink:37
bh @ browserLink:37
bp @ browserLink:37
...etc
我会注意到 $scope.totalRecords 在控制器中设置为零 (0)。将其设置为其他值不会改变任何内容。控制器中的其他一切都运行良好。
以下场景不会抛出任何错误:
<td ng-show="totalRecords=10" colspan="5">...</td>
<td ng-show="totalRecords<10" colspan="5">...</td>
<td ng-show="totalRecords>9" colspan="5">...</td>
<td ng-show="totalRecords>=11" colspan="5">...</td>
<td ng-show="totalRecords" colspan="5">...</td>
有人猜到为什么吗?
【问题讨论】:
-
试试 ng-if 而不是 ng-show?
-
您使用的是 Microsoft Visual Studio 2013 或更高版本吗?
标签: angularjs visual-studio syntax-error browser-link