angular select 用法

匿名 (未验证) 提交于 2019-12-03 00:37:01

angular select

用法1:数组

    // 循环数组     $scope.books = [         {"id": 1, "name": "Chinese", "number": "2"},         {"id": 2, "name": "English", "number": "2"},         {"id": 3, "name": "French", "number": "1"}     ]     // html     <select ng-model="ss" ng-options = "book.id as book.name for book in books">         <option value="">--请选择--</option>     </select>

用法2:对象

    // 循环对象     $scope.books = {"Chinese": 2, "English": 2, "French": 1};     // html     <select ng-model="ss" ng-options = "value for (value, key) in books">         <option value="">--请选择--</option>     </select> 

**用法3:**optgroup分组

    // 循环对象     $scope.books = {"Chinese": 2, "English": 2, "French": 1};     // html     <select ng-model="ss" ng-options = "value group by key for (value, key) in books">         <option value="">--请选择--</option>     </select>      <select ng-model="ss" ng-options = "book.id as book.name group by book.number for book in books">         <option value="">--请选择--</option>     </select>

注:ng-options与ng-model一起使用,否则会报错

文章来源: angular select 用法
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!