angular.js - ng-repeat ng-controller 的問題
黄舟
黄舟 2017-05-15 16:53:34
0
1
456

程式碼如下:

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;
    }
})

程式碼如上,頁面卻沒有顯示。不知道錯誤原因在哪裡,麻煩大神告知,謝謝了。

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

全部回覆(1)
Ty80

ng-controller="ListCtrl" 拿到table

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!