具有对象属性值&的AngularJS ng-options标题 [英] AngularJS ng-options with object attributes value & title
本文介绍了具有对象属性值&的AngularJS ng-options标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的范围内有这个数组
$scope.containers = [{id: 1, title: "Icebox"}, {id: 2, title: "Summer"},
{id: 3, title: "Milestone"}];
我可以创建类似ng-options的东西吗?
<option value="1">Icebox</option>
<option value="2">Summer</option>
<option value="3">Milestone</option>
解决方案
是的,如果您有兴趣显示标题,请使用以下方式:
<select>
<option
ng-repeat="v in containers"
value="{{v.id}}"
title="{{v.title}}"
ng-selected="adresses.indexOf(v) == 0">{{v.title}}
</option>
</select>
演示 小提琴 >
但是,如果您只想显示value
ng-options
将是光明的
I have this array in my scope
$scope.containers = [{id: 1, title: "Icebox"}, {id: 2, title: "Summer"},
{id: 3, title: "Milestone"}];
Can I create something like this ng-options?
<option value="1">Icebox</option>
<option value="2">Summer</option>
<option value="3">Milestone</option>
解决方案
Yes, if you are interested to show title use this way:
<select>
<option
ng-repeat="v in containers"
value="{{v.id}}"
title="{{v.title}}"
ng-selected="adresses.indexOf(v) == 0">{{v.title}}
</option>
</select>
Demo Fiddle
But if you want only to show value
ng-options
will be enogh
这篇关于具有对象属性值&的AngularJS ng-options标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文