Sign up ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.

Well, i need to access some information inside of array that is inside of another array in Json Format.

more specific like this:

[
  {
    "id": 1,
    "name": "PowerRanger",
    "description": "BLUE",
    "connections": 
    [ {"id": 123,"megazordName": "Fer","isSet": true},
      {"id": 456,"megazordName": "Alg","isSet": false}
    ]
    },{
     "id": 2,
     "name": "PowerRanger",
     "description": "RED",
     "connections": 
    [ {"id": 789,"megazordName": "Tes","isSet": false},
      {"id": 369,"megazordName": "EXp","isSet": true}
    ]
    },{
    "id": 3,
    "name": "PowerRanger",
    "description": "WHITE",
    "connections": 
    [ {"id": 258,"megazordName": "Ref","isSet": false},
      {"id": 147,"megazordName": "Mob","isSet": false}
    ]
    }
]

And i need to disable all the "megazordName" 's when only ONE is selected (more specifically with checkbox). Need some help :)

Here's the plunker. How can i do it?

share|improve this question

closed as unclear what you're asking by Grundy, rene, gunr2171, TylerH, Chen-Tsu Lin Apr 30 at 18:56

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

2  
so, where is problem? – Grundy Apr 30 at 15:31
    
checkout underscore.js for searching through arrays. – Dominic Scanlan Apr 30 at 15:32
    
@Sofia are you try something? – Grundy Apr 30 at 15:34
    
yeah, i builded an controller and the html , but it's not working right. – Sofia Lunkes Apr 30 at 15:36
    
so show it and we can help – Grundy Apr 30 at 15:38

1 Answer 1

I got one solution but it is not 100% what you want .

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script src="http://code.angularjs.org/1.2.0/angular.min.js"></script>
    <link href="../bootstrap/css/bootstrap.css" rel="stylesheet"/>
    <link href="../bootstrap/css/bootstrap-theme.css" rel="stylesheet"/>
    <style>
        .check-disabled-true {
            color: gray
        }

        .check-disabled-false {
            color: black
        }
    </style>
    <script>
        angular.module("atpModule", [])
                .controller("atpCtrl", function ($scope) {
                    $scope.selectedPrizemoney = 'Select one';
                    $scope.isdisabled=true;
                    $scope.atp = [
    {
    "id": 1,
    "name": "PowerRanger",
    "description": "BLUE",
    "connections": 
    [ {"id": 123,"megazordName": "Fer","isSet": true},
      {"id": 456,"megazordName": "Alg","isSet": false}
    ]
    },{
     "id": 2,
     "name": "PowerRanger",
     "description": "RED",
     "connections": 
    [ {"id": 789,"megazordName": "Tes","isSet": false},
      {"id": 369,"megazordName": "EXp","isSet": true}
    ]
    },{
    "id": 3,
    "name": "PowerRanger",
    "description": "WHITE",
    "connections": 
    [ {"id": 258,"megazordName": "Ref","isSet": false},
      {"id": 147,"megazordName": "Mob","isSet": false}
    ]
    }]


                    $scope.shouldBeDisabled = function (item) {
                        if (item.connections!= $scope.selectedPrizemoney) {                          
                            return true;
                        } else {                          
                            return false;
                        }
                    };
                });
    </script>
</head>
<body>
<div ng-app="atpModule" ng-controller="atpCtrl">

    <div id="atpPanel" class="panel">
        <h4 class="panel-header">ENABLE/DISABLE CHECKBOXES USING ANGULAR JS</h4>
        <hr/>
        <h5 class="panel-header">Select the connection:</h5>


        <select ng-model="selectedPrizemoney"  ng-options=" items.megazordName for items in atp[0].connections">
            <option value="" disabled="">Select one</option>

        </select>
        <hr/>
        <div ng-repeat="item in apt.connections">
            <p class="check-disabled-{{shouldBeDisabled(item)}}">
                <input type="checkbox" name="{{item.megazordName}}" 
                     value="{{item.megazordName}}" ng-disabled="shouldBeDisabled(item)">{{item.megazordName}}
            </p>
        </div>
    </div>
</div>
</body>
</html>
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.