无论如何我可以让ng-switch在桌子内工作吗?表示例不起作用,但ul exampel工作正常.问题是我真的需要表格示例.我正在使用角度1.07.
<table> <tbody ng-repeat="item in items"> <tr><td>{{ item.heading }}</td></tr> <tr ng-repeat="row in item.fields" ng-switch on="row.nb"> <div ng-switch-when="01"> <td>{{ row.nb }}</td> </div> </tr> </tbody> </table> <ul ng-repeat="item in items"> <li ng-repeat="row in item.fields" ng-switch on="row.nb"> <div ng-switch-when="01"> {{ row.nb }} </div> </li> </ul>
您需要将ng-switch-when移动到td,否则它会将其忽略为无效,因为div不是tr内的有效标记.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tr
删除div并将其更改为:
<td ng-switch-when="01">{{ row.nb }}</td>