ng-repeat与单选按钮表现奇怪

时间:2015-05-07 09:02:51

标签: angularjs angularjs-ng-repeat haml

在我的Angular应用中,我使用单选按钮的chosen状态来确定是否出现“确认”按钮:

%label.btn.btn-primary.btn-lg.btn-block
      %input{:type => "radio", :id => "option 1", :autocomplete => "off", :value => "Option 1", "ng-model" => "chosen"}  Option 1
%button.btn.btn-success.btn-lg.btn-block{"ng-if"=>"chosen"} Confirm: {{chosen}}

这很好用。但是,当我使用ng-repeat生成单选按钮时,按下按钮时不再显示确认按钮

%label.btn.btn-primary.btn-lg.btn-block{"ng-repeat" => "(key, ans) in currentTask.answers"}
      %input{:type => "radio", :id => "option {{key}}", :autocomplete => "off", "ng-value" => "Option {{key}}", "ng-model" => "chosen"}  Option {{key}}
常规HTML中的

编辑

<label class="btn" ng-repeat = "(key, ans) in topic">
   <input type = "radio" id = "option {{key}}" autocomplete = "off" ng-value = "Option {{key}}" ng-model = "chosen">option
   </input>
</label>
<button ng-if="chosen"> Confirm: {{chosen}} </button>

0 个答案:

没有答案
相关问题