【发布时间】:2015-05-04 01:38:12
【问题描述】:
我正在学习 AngularJS 和用户输入。在我的代码中,我尝试使用“选中”和“选中”设置下拉菜单和单选按钮的默认状态。
但是,它们不能与“ng-model”属性一起使用。
另外,对于第一个单选按钮(升序),空值属性似乎阻碍了“checked”属性。
谁能解释为什么会发生这种情况以及如何绕过这个问题?
<div class="search">
<h1>Artist Directory</h1>
<label> Search: </label>
<input ng-model="query" placeholder="Search for artists" autofocus>
<label class="formgroup">by:
<select ng-model="listOrder" name="direction">
<option value ="name" selected="selected"> Name</option>
<option value="reknown"> Reknown</option>
</select>
</label>
<label class="formgroup">
<input ng-model="direction" type="radio" value=" " checked> Ascending
</label>
<label class="formgroup">
<input ng-model="direction" type="radio" value="reverse"> Descending
</label>
</div>
【问题讨论】:
-
请提供小提琴。这将帮助我们帮助您:)
标签: html angularjs input option radio