私はラジオボタンのセットとチェックボックスの配列を持っています。私はradiobutton1をクリックすると、配列から最初のチェックボックス要素を読み込む必要があります。radiobutton2をクリックすると、残りの3つのチェックボックス要素がarray.Butから読み込まれます。両方の場合に4つのチェックボックスがすべて表示されます。私はこのようにしてみました。コントローラチェックボックスの配列のチェックボックス要素を表示
App.controller('ReportController', ['$scope', 'Report', function($scope, Report){
var self = this;
$scope.channels = [{ name: 'A', selected: false, value: '1',visible:false },
{ name: 'B', selected: false, value: '2' ,visible:false},
{ name: 'C', selected: false, value: '3' ,visible:false},
{ name: 'D', selected: false, value: '4' ,visible:false}
];
$scope.selection = [];
$scope.selectedChannels = function selectedChannels() {
return Report($scope.channels, { selected: true });
};
$scope.$watch('channels|filter:{selected:true}', function (new) {
$scope.selection = new.map(function (channel) {
return channel.value;
});
}, true);
$scope.myFilter = function(){
if ($scope.radioption == '1'){
return $scope.channels[0].visible = true;
}
else if ($scope.radioption == '2'){
return [$scope.channels[1],{ visible: true },
$scope.channels[2],{ visible: true },
$scope.channels[3],{ visible: true }];
}
});
}]);
なぜフィルタを使用していて、ng-showまたはng-hideディレクティブではないのですか? – karman
通常のチェックボックスについては、ng-showの使い方を知っています。配列のために私はそれを使用する方法を知らない。私はangularjsを初めて使っています。 – user3844782