最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

AngularJS學(xué)習(xí)筆記之ng-options指令

 更新時(shí)間:2015年06月16日 10:09:00   投稿:hebedich  
ng-options是angular-1.3新出的一個(gè)指令,這篇文章就來介紹這個(gè)指令的用法.有需要的小伙伴可以參考下。

1.基本下拉效果(lable for value in array)

  其中select標(biāo)簽中的ng-model屬性必須有,其值為選中的對(duì)象或?qū)傩灾怠?/p>

<div ng-controller="ngselect">
  <p>usage:label for value in array</p>
  <p>選項(xiàng),{{selected}}</p>
  <select ng-model="selected" ng-options="o.id for o in optData">
    <option value="">-- 請(qǐng)選擇 --</option>
  </select>
</div>
m1.controller("ngselect",['$scope',function($sc){
  $sc.selected = '';
  $sc.optData = [{
    id: 10001,
    MainCategory: '男',
    ProductName: '水洗T恤',
    ProductColor: '白'
  },{
    id: 10002,
    MainCategory: '女',
    ProductName: '圓領(lǐng)短袖',
    ProductColor: '黃'
  },{
    id: 10003,
    MainCategory: '女',
    ProductName: '圓領(lǐng)短袖',
    ProductColor: '黃'
  }];
}]);

2.自定義下拉顯示名稱(label for value in array)

    label可以根據(jù)需要拼接出不同的字符串

<div ng-controller="ngselect2">
  <p>usage:label for value in array(label可以根據(jù)需求拼接出不同的字符串)</p>
  <p>選項(xiàng),{{selected}}</p>
  <select ng-model="selected" ng-options="(o.ProductColor+'-'+o.ProductName) for o in optData">
    <option value="">-- 請(qǐng)選擇 --</option>
  </select>
</div>
m1.controller("ngselect2",['$scope',function($sc){
  $sc.selected = '';
  $sc.optData = [{
    id: 10001,
    MainCategory: '男',
    ProductName: '水洗T恤',
    ProductColor: '白'
  },{
    id: 10002,
    MainCategory: '女',
    ProductName: '圓領(lǐng)短袖',
    ProductColor: '黃'
  },{
    id: 10003,
    MainCategory: '女',
    ProductName: '圓領(lǐng)短袖',
    ProductColor: '黃'
  }];
}]);

3.ng-options 選項(xiàng)分組

    group by分組項(xiàng)

<div ng-controller="ngselect3">
  <p>usage:label group by groupName for value in array</p>
  <p>選項(xiàng),{{selected}}</p>
  <select ng-model="selected" ng-options="(o.ProductColor+'-'+o.ProductName) group by o.MainCategory for o in optData">
    <option value="">-- 請(qǐng)選擇 --</option>
  </select>
</div>
m1.controller("ngselect3",['$scope',function($sc){
  $sc.selected = '';
  $sc.optData = [{
    id: 10001,
    MainCategory: '男',
    ProductName: '水洗T恤',
    ProductColor: '白'
  },{
    id: 10002,
    MainCategory: '女',
    ProductName: '圓領(lǐng)長袖',
    ProductColor: '黃'
  },{
    id: 10003,
    MainCategory: '女',
    ProductName: '圓領(lǐng)短袖',
    ProductColor: '黃'
  }];
}]);

4.ng-options 自定義ngModel的綁定

    下面selected的值為optData的id 效果 http://sandbox.runjs.cn/show/nhi8ubrb

<div ng-controller="ngselect4">
  <p>usage:select as label for value in array</p>
  <p>選項(xiàng),{{selected}}</p>
  <select ng-model="selected" ng-options="o.id as o.ProductName for o in optData">
    <option value="">-- 請(qǐng)選擇 --</option>
  </select>
</div>
m1.controller("ngselect4",['$scope',function($sc){
  $sc.selected = '';
  $sc.optData = [{
    id: 10001,
    MainCategory: '男',
    ProductName: '水洗T恤',
    ProductColor: '白'
  },{
    id: 10002,
    MainCategory: '女',
    ProductName: '圓領(lǐng)長袖',
    ProductColor: '黃'
  },{
    id: 10003,
    MainCategory: '女',
    ProductName: '圓領(lǐng)短袖',
    ProductColor: '黃'
  }];
}]);

效果:http://runjs.cn/detail/nhi8ubrb

以上所述就是本文的全部內(nèi)容了,希望大家能夠喜歡。

相關(guān)文章

最新評(píng)論

满城县| 五河县| 和顺县| 哈巴河县| 大新县| 扎鲁特旗| 绥芬河市| 孟津县| 沽源县| 盘锦市| 武功县| 台中县| 尼勒克县| 贵南县| 图们市| 安徽省| 上高县| 沅陵县| 靖州| 海淀区| 澎湖县| 长垣县| 上饶县| 临泽县| 司法| 宜丰县| 漳浦县| 任丘市| 花莲市| 五河县| 信宜市| 云霄县| 龙山县| 元阳县| 东乡县| 托里县| 新田县| 朔州市| 防城港市| 白朗县| 进贤县|