新聞中心
這篇文章主要介紹angularjs中select賦值ng-options配置的示例分析,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
為鹽亭等地區(qū)用戶(hù)提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及鹽亭網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為網(wǎng)站設(shè)計(jì)制作、成都做網(wǎng)站、鹽亭網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專(zhuān)業(yè)、用心的態(tài)度為用戶(hù)提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶(hù)的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
數(shù)組方式
數(shù)據(jù)是數(shù)組
$scope.years = [2014, 2015, 2016];
頁(yè)面元素
設(shè)置默認(rèn)值
如果需要設(shè)置默認(rèn)的選項(xiàng),可以先設(shè)置一個(gè)參數(shù):
$scope.item = 2016; $scope.years = [2014, 2015, 2016];
對(duì)象數(shù)組方式
數(shù)據(jù)是對(duì)象數(shù)組
$scope.sites = [ {site : "baidu", url : "https://www.baidu.com"}, {site : "163", url : "http://www.163.com"}, {site : "sina", url : "http://www.sina.com"} ];
頁(yè)面元素
設(shè)置默認(rèn)值
如果需要設(shè)置默認(rèn)的選項(xiàng),可以先設(shè)置一個(gè)參數(shù):
$scope.site = "163"; $scope.sites = [ {site : "baidu", url : "https://www.baidu.com"}, {site : "163", url : "http://www.163.com"}, {site : "sina", url : "http://www.sina.com"} ];
Key-Vules對(duì)象數(shù)組方式
數(shù)據(jù)是對(duì)象數(shù)組
$scope.cars = { car1 : {brand : "BYD", model : "Y50", color : "red"}, car2 : {brand : "CC", model : "HF", color : "white"}, car3 : {brand : "JL", model : "JL10D", color : "black"} };
頁(yè)面元素
設(shè)置默認(rèn)值
如果需要設(shè)置默認(rèn)的選項(xiàng),可以先設(shè)置一個(gè)參數(shù):
$scope.site = "BYD"; $scope.cars = { car1 : {brand : "BYD", model : "Y50", color : "red"}, car2 : {brand : "CC", model : "HF", color : "white"}, car3 : {brand : "JL", model : "JL10D", color : "black"} };
angularjs ng-options官方API
數(shù)組類(lèi)型:
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 group for value in array track by trackexpr
對(duì)象類(lèi)型:
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 group for (key, value) in ob
以上是“angularjs中select賦值ng-options配置的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
新聞標(biāo)題:angularjs中select賦值ng-options配置的示例分析
轉(zhuǎn)載源于:http://fisionsoft.com.cn/article/gicics.html