>  Q&A  >  본문

angular.js - ng-repeat ng-controller 的问题

代码如下:

html    <table class="table table-bordered">
        <tbody ng-repeat="user in users" ng-controller="ListCtrl"  ng-switch on="" ng-click="toggleSelected()"  ng-switch on="isSelectedAll()" >
            <tr>
                    <td>{{user.name}}</td>
                    <td>{{user.email}}</td>
            </tr> 
            <tr ng-switch-when="true">
                <td colspan="2">{{user.desc}}</td>
            </tr>
        </tbody>
    </table>
jsangular.module('listApp', []);

angular.module('listApp').controller('ListCtrl',function($scope){

    $scope.users = [
        {name:'马春娣',email:'macd@xx.com.cn',desc:'我们比比谁先到家'},
        {name:'邹俊',email:'zenj@xx.com.cn',desc:'300斤有我!'},
        {name:'曾贱',email:'zoujian@xx.com.cn',desc:'我胸大,我说了算!'}
    ];

    $scope.isSelected = false;
    $scope.toggleSelected = function(){
        $scope.isSelected = ! $scope.isSelected;
    };

    $scope.isSelectedAll = function(){
        return $scope.isSelected;
    }
})

代码如上,页面却没有显示。不知道错误原因在哪儿,麻烦大神告知,谢谢了。

黄舟黄舟2714일 전464

모든 응답(1)나는 대답할 것이다

  • PHP中文网

    PHP中文网2017-05-15 16:55:34

    ng-controller="ListCtrl" 拿到table 위로

    회신하다
    0
  • 취소회신하다