zoukankan      html  css  js  c++  java
  • angularJS select

    ng-options指令

      在angularJS中创建select下拉是使用ng-options创建下拉项

    ng-options="val as label for element in array"  //设置option的value值为val

    ng-options="lable for element in array"  //不设置option的value值,默认为element对象

    ng-options="(label)group by group for element in array"  //不设置option的value值,默认为element对象

     

    <div ng-controller="selectCtrl">
        <select ng-model="menu" ng-options="m.id as m.name for m in selectArray"></select>
        {{menu}}
    </div>
    myApp.controller('selectCtrl',function($scope){
        $scope.selectArray=[
            {id:'1', name:'apple'},
            {id:'2', name:'pear'}
        ]
    })

  • 相关阅读:
    JavaScript
    多线程
    MySQL进阶一(基础查询)
    英语语法随笔1
    MySQL
    Love Story
    两个数组的交集
    只出现一次的数字
    MybatisPlus
    数组中值加一
  • 原文地址:https://www.cnblogs.com/zhang-jian/p/5344613.html
Copyright © 2011-2022 走看看