2017-06-21 7 views
0

が選択されていない最初のラジオボタンを選択するコントローラは、しかし、私は缶が適切ラジオボタンを印刷私のHTMLでラジオボタン他のラジオボタンがここ

app.controller('testController',function($scope){ 

    $scope.categorys = [ 
       {name:'Paintings',value:'1'}, 
       {name:'Photography',value:'2'}, 
       {name:'Drawings',value:'3'}, 
       {name:'Sculpture',value:'4'} 
      ]; 
}) 

<div class="grid-two" ng-repeat="category in categorys"> 
           <div class="image-thumb"> 
            <p>{{category.name}}</p> 
            <figure> 
             <img src="/images/1.jpg"> 
            </figure> 
            <input ng-model="art.category" ng-value="category.value" type="radio" id="seling3"/> 
            <label for="seling3" class="blue-overlay"> 
             <i class="icon icon-tick c-sprite"></i> 
            </label> 
           </div> 
          </div> 

あります最初のラジオボタンを選択してください他のラジオボタンは選択されていません 私は非常に多くの質問を試みましたが、それらのどれも私の問題と似ていない問題

答えて

0

input[type="radio"]に異なるIDを与える:

<input ng-model="art.category" ng-value="category.value" type="radio" 
id="seling{{category.value}}"/> 
<label for="seling{{category.value}}" class="blue-overlay"> 
    <i class="icon icon-tick c-sprite"></i> 
</label> 
+0

おかげで問題のようなコントローラでart.categoryオブジェクトを定義します:) – Jabaa

0

は、ポイントのために、この

app.controller('testController',function($scope){ 
     $scope.art = {'category' : ''} 
}) 

デモ

angular.module("app",[]) 
 
.controller("ctrl",function($scope){ 
 
    $scope.art = {'category' : ''} 
 
    $scope.categorys = [ 
 
     {name:'Paintings',value:'1'}, 
 
     {name:'Photography',value:'2'}, 
 
     {name:'Drawings',value:'3'}, 
 
     {name:'Sculpture',value:'4'} 
 
    ]; 
 
})
<figure> 
 
             <img src="/images/1.jpg"> 
 
            </figure>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
<div ng-app="app" ng-controller="ctrl"> 
 
<div class="grid-two" ng-repeat="category in categorys"> 
 
           <div class="image-thumb"> 
 
            <p>{{category.name}}</p> 
 
            <figure> 
 
             <img src="/images/1.jpg"> 
 
            </figure> 
 
            <input ng-model="art.category" ng-value="category.value" type="radio" id="seling3"/> 
 
            <label for="seling3" class="blue-overlay"> 
 
             <i class="icon icon-tick c-sprite"></i> 
 
            </label> 
 
           </div> 
 
          </div> 
 
</div>

関連する問題