在我的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>