angular.js - angular 的ng-option的一些参数option.id as option.title 这里面的as是
给我你的怀抱
给我你的怀抱 2017-05-15 17:02:25
[AngularJS讨论组]

如下这段代码,as是什么意思?

ng-options="option.id as option.title for option in curOptionArray"
给我你的怀抱
给我你的怀抱

全部回复(4)
大家讲道理

option.id表示选择的,
option.title表示显示的,
as就是这个作用

伊谢尔伦

可以理解成一个ng的语法 option.id是select提交的值 option.title是select显示的值 option代表数组curOptionArray里面的当前元素

迷茫

可参考官网:
https://docs.angularjs.org/api/ng/directive/ngOptions#!

其中有一个例子:

$scope.items = [{
  id: 1,
  label: 'aLabel',
  subItem: { name: 'aSubItem' }
}, {
  id: 2,
  label: 'bLabel',
  subItem: { name: 'bSubItem' }
}];

<select ng-options="item as item.label for item in items track by item.id" ng-model="selected"></select>
PHPz

可以看看这里Hacking with Angular: 玩转ngOptions指令

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号