加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular中的 input select 值绑定无效,以及多出一个空白选项问

发布时间:2020-12-17 07:02:42 所属栏目:安全 来源:网络整理
导读:问题: !-- 问题标签 -- select ng-model ="sortType" option value ="1" 按日统计 / option option value ="2" 按月统计 / option / select ?可以通过将一下方式处理完成 1、select中的option选项通过循环方式渲染 select ng-options ="item.sortType as it

问题:

<!-- 问题标签 -->
<select ng-model="sortType">
    <option value="1">按日统计</option>
    <option value="2">按月统计</option>
</select>

?可以通过将一下方式处理完成

1、select中的option选项通过循环方式渲染

<select ng-options="item.sortType as item.sortTypeName for item in sortTypeArr" ng-model="sortType"></select>
$scope.sortTypeArr = [
    {
        sortType: 1,sortTypeName: ‘按日统计‘
    },{
        sortType: 2,sortTypeName: ‘按月统计‘
    }
]

2、select的绑定值不能绑为空

3、标签中的value属性改为ng-value

<select ng-model="sortType">
    <option ng-value="1">按日统计</option>
    <option ng-value="2">按月统计</option>
</select>
<label>
    <input type="radio" ng-model="sortType" ng-value="1">        
</label>
<label>
    <input type="radio" ng-model="sortType" ng-value="2">        
</label>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读