Error: $compile:ctreq
Missing Required Controller
Controller 'ngSwitch', required by directive 'ngSwitchWhen', can't be found!
<div class="item" ng-repeat="item in list">
<!--0表进行中,1表已提车, 2表待结账-->
<div ng-switch="item.state.value">
<div ng-switch-when="0" class="ui top right attached label yellow">服务中</div>
<div ng-switch-when="1" class="ui top right attached label red">已结账</div>
<div ng-switch-when="2" class="ui top right attached label orange">待结账</div>
<div ng-switch-default class="ui top right attached label">已挂账</div>
</div>
</div>
ng-repeat每个循环都会创建一个scope
修改为:
<div class="item" ng-repeat="item in list" ng-switch="item.state.value">
<!--0表进行中,1表已提车, 2表待结账-->
<div ng-switch-when="0" class="ui top right attached label yellow">服务中</div>
<div ng-switch-when="1" class="ui top right attached label red">已结账</div>
<div ng-switch-when="2" class="ui top right attached label orange">待结账</div>
<div ng-switch-default class="ui top right attached label">已挂账</div>
</div>
AngularJS ng-repeat下使用ng-model
<table> <tr ng-repeat="row in collections"> <td> {{row.name}}: <input type="radio" value="{{row.value}}" ng-model="selectValue"/> </td> </tr> </table>
当你书写了上述代码后。你会发现点击其中的对话框,$scope.selectValue中并没有保存你选中的对应单选框的值。
这是因为处在ng-repeat之间的代码,对全局的$scope里变量的内容是不可见的,而是为ng-repeat创建的子scope里面的。
所以要引用ng-repeat $scope里的成员,你可以使用$parent
<table> <tr ng-repeat="row in collections"> <td> {{row.name}}: <input type="radio" value="{{row.value}}" ng-model="$parent.selectValue"/> </td> </tr> </table>