AngularJS remove & add select box option if other selection changes

后端 未结 3 507
囚心锁ツ
囚心锁ツ 2021-01-06 10:55

I\'m looking for a similar solution to a problem that has been resolved before with the following code:

http://jsfiddle.net/yLCVf/1/

This is the JS that I\'m

3条回答
  •  醉酒成梦
    2021-01-06 11:16

    $scope.filesList    = FileService.getFiles();
    $scope.listsList    = [];
    $scope.items = ['settings', 'home', 'other'];
    $scope.selection = $scope.items[0];
    //esse scope file options mudará depois vou pegar diretamente do banco.
    $scope.filesOptions = [
        {
            'filetype'  : 1,
            'filelabel' : 'OPÇÃO A',
            'selected'  : false
        },
        {
            'filetype'  : 2,
            'filelabel' : 'OPÇÃO B',
            'selected'  : false
        },
        {
            'filetype'  : 3,
            'filelabel' : 'OPÇÃO C',
            'selected'  : false
        },
        {
            'filetype'  : 4,
            'filelabel' : 'OPÇÃO D',
            'selected'  : false
        },
        {
            'filetype'  : 5,
            'filelabel' : 'OPÇÃO E',
            'selected'  : false
        }
    ];
    
     for (index = 0; index < $scope.filesList.length; ++index) {
    
    $scope.listsList.push({list: angular.copy($scope.filesOptions), option: null});}
    
    $scope.onChange = function(){
        //tgt.selected = true;
        for (var i = 0; i < $scope.listsList.length; ++i) {
            var current = $scope.listsList[i];
            $scope.enableAllOptions(current.list);
            for (var j = 0; j < $scope.listsList.length; ++j) {
                if(current != $scope.listsList[j]){
                    $scope.disableOptions(current.list, $scope.listsList[j].list, $scope.listsList[j].option);
                }
            }
        }
    };
    //Enable all options by default.
    $scope.enableAllOptions = function(arr){ for(var i=0;i=0) destArr[index].selected = true;
        }
    };
    
    
    
    提交评论

提交回复
热议问题