javascript – AngularJS ng-options将数据类型添加到选项的值

前端之家收集整理的这篇文章主要介绍了javascript – AngularJS ng-options将数据类型添加到选项的值前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
尝试使用AngularJS和ng-options的最新版本(1.5.8)来填充下拉列表.

问题是它正在添加数据类型以及值,如下所示:

<select class="possedetail ng-valid ng-dirty ng-valid-parse ng-touched" ng-model="Province" ng-options="p as p for p in provList">
<option value="string:ALBERTA" label="ALBERTA">ALBERTA</option>
<option value="string:BRITISH COLUMBIA" label="BRITISH COLUMBIA">BRITISH COLUMBIA</option></select>

我需要字符串:艾伯塔省……

这是我的数据来源:

$scope.provList = ["ALBERTA","BRITISH COLUMBIA","MANITOBA","NEW BRUNSWICK","NEWFOUNDLAND AND LABRADOR","NORTHWEST TERRITORIES","NOVA SCOTIA","NUNAVUT","ONTARIO","PRINCE EDWARD ISLAND","QUEBEC","SASKATCHEWAN","YUKON",];

我已阅读google文档,在网上搜索并尝试将我的数据源格式更改为[{name:“Alberta”},{name:“BC”}] …

请帮忙,不管怎么说?

解决方法

这可能有点晚,但在你的ng-options表达式中添加“track by”可以解决你的问题.即
<select ng-model="Province" ng-options="p for p in provList track by p"></select>
原文链接:https://www.f2er.com/js/155200.html

猜你在找的JavaScript相关文章