angular select 根据后台传回的1,2在页面显示是否,并默认选中

ng-model其实是有赋值给select的,只是赋值的方式是一个对象,也就是"value=?number:4?"这样,而option中没有与之对应的值,所以没有被默认选中;
ng-options用的是as...for...这种形式,将option的value设置为“number:3”这种形式,与ng-model的值的形式是对应的,所以ng-model能找到对应值,因此才选中;
js部分:
$scope.equityStructurelist=$scope.baseInfos.enterpriseEquityStructure;
                $scope.aaa=$scope.baseInfos.enterpriseBasicInfoWithBLOBs.nsnenterpriseflag;
 //后台传回1,2
 $scope.bbb=$scope.baseInfos.enterpriseBasicInfoWithBLOBs.ecgmvflag; //后台传回1,2
 $scope.aObj=[{"id":1,"name":"是"},{"id":2,"name":"否"};  //自定义一个对象

页面部分:
<select name="nsnEnterpriseFlag" id="nsnEnterpriseFlag" class="form-control" ng-model = "aaa" ng-options= "a.id as a.name for a in aObj"></select>
<select name="ecGmvFlag" id="ecGmvFlag" class="form-control" ng-model="bbb" ng-options="b.id as b.name for b in aObj" ></select>













评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值