文章詳情頁
angular.js - ng-model如何綁定二選一的單選項框?
瀏覽:200日期:2024-09-23 17:03:46
問題描述
問題解答
回答1:<label> <input type='radio' ng-model='sex' value='male'> <span>男</span></label><label> <input type='radio' ng-model='sex' value='female'> <span>女</span></label>{{sex}}
至于name屬性,我試了一下只要ng-model綁定的值一樣就認為是一組
回答2:用ng-checked來
<label class=''> <input type='radio' ng-checked='option==1' ng-click='option=1'> <span>a</span></label><label class=''> <input type='radio' ng-checked='option==2' ng-click='option=2'> <span>b</span></label>回答3:
單選框少了name屬性,瀏覽器怎么知道你是一組單選框,angular怎么知道是一組單選框?
相關文章:
1. javascript - 原生canvas中如何獲取到觸摸事件的canvas內坐標?2. showpassword里的this 是什么意思?代表哪個元素3. mysql scripts提示 /usr/bin/perl: bad interpreter4. css3 - css怎么實現圖片環繞的效果5. html - vue項目中用到了elementUI問題6. 對mysql某個字段監控的功能7. java - spring boot @Autowired8. JavaScript事件9. css3 - border-bottom 的長度可否超過盒子的寬度呢?實現如下圖效果。(我的書下面的線)10. mysql優化 - mysql EXPLAIN之后怎么看結果進行優化 ?
排行榜
