Angularjs ng-options循环json数据问题及解决方案

1、数据

 

[{"code":"subwayLine1"},{"code":"subwayLine2"},{"code":"subwayLine3"},{"code":"subwayLine4"},{"code":"subwayLine5"},{"code":"subwayLine6"},{"code":"subwayLine7"},{"code":"subwayLine8"}]

 

 

2、ng-options循环下拉列表

 

<select class="form-control" ng-model="code" ng-options="v.code for v in codeList">
  <option value="">--请选择--</option>
</select>

 结果查询参数错误(code: $scope.code):

form表单内容:

code[code]:subwayLine1

 解决方案之一:

var params = {
  code: $scope.code
};

 

解决方案之二:

<select class="form-control" ng-model="code">
  <option value="">--请选择--</option>
  <option ng-repeat="v in codeList">{{v.code}}</option>
</select>

 

ng-options使用指南:http://each.sinaapp.com/angular/tutorial/ng-options.html

 

 

 

若有疑问,请发表评论或添加微信为你解答:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值