亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Angular 中 select指令用法詳解

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

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

  select用法:

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

  屬性說明:

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

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

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

  數(shù)據(jù)源為數(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ù)源為對象時,用法:

   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ù)組/對象

   label:option選項顯示的名稱。

   select:是選中某一項后,綁定到ngModel的值。

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

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

   group by groupexpr:用于選項分組,

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

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

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

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

相關(guān)文章

最新評論