欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Angular 中 select指令用法詳解

 更新時(shí)間:2016年09月29日 15:03:22   作者:我輩中人  
這篇文章主要介紹了Angular 中 select指令用法詳解的相關(guān)資料,本文介紹的非常詳細(xì),具有參考借鑒價(jià)值,需要的朋友可以參考下

最近在angular中使用select指令時(shí),出現(xiàn)了很多問題,搞得很郁悶。查看了很多資料后,發(fā)現(xiàn)select指令并不簡(jiǎn)單,決定總結(jié)一下。

  select用法:

<select
ng-model=""
[name=""]
[required=""]
[ng-required=""]
[ng-options=""]>
</select>

  屬性說明:

  發(fā)現(xiàn)并沒有ng-change屬性

  ng-required:當(dāng)屬性值為true時(shí),對(duì)select添加required驗(yàn)證,為false時(shí)不驗(yàn)證。

  ng-options:指定數(shù)據(jù)源,生成option選項(xiàng)。

  數(shù)據(jù)源為數(shù)組時(shí),用法:

   label for value in array
   select as label for value in array
   label group by group for value in array
   select as label group by groupexpr for value in array track by trackexpr

 數(shù)據(jù)源為對(duì)象時(shí),用法:

   label for (key,value)in object
   select as label for(key,value)in object
label group by group for(key,value)in object
select as label group by groupexpr for (key,value)in object track by trackexpr  

 具體說明:

   array/object:數(shù)組/對(duì)象

   label:option選項(xiàng)顯示的名稱。

   select:是選中某一項(xiàng)后,綁定到ngModel的值。

value : 數(shù)組中的值。

 ?。╧ey,value):對(duì)象的key,value。

   group by groupexpr:用于選項(xiàng)分組,

 ng-options與ng-repeat自動(dòng)生成option選項(xiàng)的區(qū)別:

 ng-options生成的option選項(xiàng)選中后,綁定到ngModel的值可以是對(duì)象。ng-repeat綁定到ngModel的值只能是字符串。

注意:select初始化時(shí)需要為ngModel指定值,否則會(huì)出現(xiàn)空白選項(xiàng)。

以上所述是小編給大家介紹的Angular 中 select指令用法詳解,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論