angular.js - angular 的ng-option的一些參數option.id as option.title 這裡面的as是
给我你的怀抱
给我你的怀抱 2017-05-15 17:02:25
0
4
652

如下這段程式碼,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>
PHPzhong

可以看看這裡Hacking with Angular: 玩轉ngOptions指令

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板