angular.js 当 ng-repeat 遇上 checkbox

学习ng 发现 ng-repeat 嵌套 checkbox 和 radio 的时候有问题,最后临时的解决方法,写一下。

[code]
<select ng-model="absentType" name="absentType" ng-options="m.name for m in absentTypeList">
</select>
<p ng-repeat="m in absentTypeList" >
<input type="radio" id="" ng-model="$parent.key" ng-click="sa($index)" name="type1" ng-value="m"/><label>{{m.name}}</label>
</p>[/code]
js

[code](function (app) {

app.controller('uc.data.ziliao.controller', ['$scope', 'modelAbsentType','modelQingjiaList', 'alertMsg','$q', function ($scope,modelAbsentType, modelQingjiaList,alertMsg,$q) {

    $('#timeStart,#timeEnd').die().datetimepicker({
        closeOnDateSelect: true,
        format: 'Y-m-d H:i',
        lang: 'ch',
        timepicker: true
    });

    modelAbsentType.list({
        schoolid: $scope.schoolStudentData.schoolid
        //,semesterid:$scope.semesterData.id
    },
    function(rs){
        $scope.absentTypeList =rs.data;
        $scope.key = $scope.absentTypeList[0];

    },
    function(){});

    $scope.sa = function(e){
        $scope.key = $scope.absentTypeList[e];
        console.log($scope.key.name);
    }

    ///

    modelQingjiaList.list({
            schoolid: $scope.schoolStudentData.schoolid
            ,semesterid:$scope.semesterData.id
        },
        function(rs){
            $scope.qingjiaList =rs.data;

        },
        function(){});

}]);

})(angular.module('uc.data.ziliao', []));[/code]

这样点击 checkbox 的时候 能打印出相应的选项。

评论 ( 0 )
最新评论
暂无评论

赶紧努力消灭 0 回复