title: Display selected radio button from JSON in angularJS
body: <p>I want the radio button to be selected depending on the given JSON format.</p>
  
  <pre><code>{
      "autoselect": [
        "fugiat"
      ], 
      "component": "radio", 
      "description": "necessitatibus accusantium aliquid iste non", 
      "editable": false, 
      "label": "in sunt", 
      "options": [
        "fugiat", 
        "commodo hic", 
        "exercitationem"
      ], 
      "required": true
    },
    {
      "component": "radio", 
      "description": "necessitatibus accusantium aliquid iste non", 
      "editable": false, 
      "label": "in sunt", 
  
      "options": [
        "fugiat", 
        "commodo hic", 
        "exercitationem"
      ], 
      "required": true
    }
  </code></pre>
  
  <p>Radio button should display on the basis of number of element in <code>options</code> array.
  And the value of radio button based on <code>autoselect</code>value. If <code>autoselect</code>value match with any value of <code>options</code> then corresponding option radio button will be true and remaining will false.</p>
  
  <p>And if JSON object does not contain <code>autoselect</code> value then none of the radio buttons should be selected initially.</p>
  
  <p>HTML code</p>
  
  <pre><code>&lt;div data-ng-if="formData.component=='radio'" class="form-group"&gt;
                      &lt;label class="col-sm-2 control-label"&gt;{{formData.label}} : &lt;/label&gt;&lt;br&gt;
                      &lt;div class="col-sm-8"&gt;
                              &lt;div class="row"  data-ng-repeat="option in formData.options"
                                   data-ng-disabled="{{!formData.editable}}"
                                   data-ng-required="{{formData.required}}"&gt;
                                  &lt;label class="col-sm-4"&gt;{{option}} : &lt;/label&gt;
                                   &lt;div data-ng-if="formData.hasOwnProperty('autoselect')" data-ng-repeat="autoselect in formData.autoselect"&gt;
                                      &lt;div data-ng-if="option === autoselect"&gt; 
                                          &lt;input class="col-sm-1" type="{{formData.component}}" data-ng-model="radioAction.checked"&gt;
                                      &lt;/div&gt;
                                      &lt;div data-ng-if="option !== autoselect"&gt;
                                          &lt;input class="col-sm-1" type="{{formData.component}}" data-ng-model="!radioAction.checked"&gt;
                                      &lt;/div&gt; 
                                  &lt;/div&gt;
                                  &lt;div data-ng-if="!formData.hasOwnProperty('autoselect')"&gt;
                                      &lt;input class="col-sm-1" type="{{formData.component}}" data-ng-model="radioAction"&gt;
                                  &lt;/div&gt;
                               &lt;/div&gt; 
                      &lt;/div&gt;
                  &lt;/div&gt;
  </code></pre>
  
  <p>Contoller.js</p>
  
  <pre><code>$http.get("data.json")
          .then(function(response){ 
              $scope.formDatas = response.data.data; 
              console.log($scope.formDatas);
              //$scope.autoSelect = $scope.formDatas.form_fields.autoselect[0];
          });
  </code></pre>
  
  <p>when autoselect values is not there that time my code is not working.</p>
  
  <p>Kindly help me in particular scenario.
  <a href="http://plnkr.co/edit/1ZTmjBV21xZDvWrG3XqY?p=preview" rel="nofollow noreferrer">code is here: plunker</a></p>
  
  <p>Thanks in advance..</p>