How to get checkbox value in angularjs?

后端 未结 4 608
故里飘歌
故里飘歌 2021-01-04 09:00

I have a 10(or n)checkbox in my ng-view. Now I would like to ask here that What is the most efficient or simple way to check if checkbox is checked and if checked get the v

4条回答
  •  一向
    一向 (楼主)
    2021-01-04 10:01

    Have a look at this fiddle,i have used the object whose key is the album name

    controller:

    function ctrl($scope){
    $scope.albums = [{name:'a1'},{name:'a2'},{name:'a3'}];
    $scope.folder = {};
    $scope.albumNameArray = [];
    $scope.getAllSelected = function(){          
        angular.forEach($scope.folder,function(key,value){
            if(key)
                $scope.albumNameArray.push(value)
        });
    }}
    

提交回复
热议问题