Angular Material - 选择框小部件
md-select,一个 Angular 指令,用于显示由 ng-model 限制的选择框。
属性 - md-radio-group
下表列出了md-radio-group不同属性的参数及说明。
Sr.No | 参数和描述 |
---|---|
1 | * ng-model 模型! |
2 | multiple 是否是多个。 |
3 | md-on-close 关闭选择时要计算的表达式。 |
4 | placeholder 占位符提示文本。 |
5 | baria-label
用于辅助功能的可选标签。 仅当不存在占位符或显式标签时才需要。 |
6 | md-container-class 要应用于 .md-select-menu-container 元素的类列表(用于自定义样式)。 |
示例
以下示例展示了 md-select
的使用,展示了选择框的使用。
am_selects.html
<html lang = "en"> <head> <link rel = "stylesheet" href = "https://www.w3ccoo.com/lib/angular_material/1.0.0/angular-material.min.css"> <script src = "https://cdn.staticfile.org/angular.js/1.4.8/angular.min.js"></script> <script src = "https://cdn.staticfile.org/angular.js/1.4.8/angular-animate.min.js"></script> <script src = "https://cdn.staticfile.org/angular.js/1.4.8/angular-aria.min.js"></script> <script src = "https://cdn.staticfile.org/angular.js/1.4.8/angular-messages.min.js"></script> <script src = "https://www.w3ccoo.com/lib/angular_material/1.0.0/angular-material.min.js"></script> <link rel = "stylesheet" href = "https://fonts.googleapis.com/icon?family=Material+Icons"> <script language = "javascript"> angular .module('firstApplication', ['ngMaterial']) .controller('selectController', selectController); function selectController ($scope) { $scope.users = [ { id: 1, name: 'Mahesh' }, { id: 2, name: 'Ramesh' }, { id: 3, name: 'Sohan' } ]; $scope.selectedUser = { id: 2, name: 'Ramesh' }; $scope.drinks = [ { category: 'hard', name: 'Beer' }, { category: 'hard', name: 'Rum' }, { category: 'hard', name: 'Vodka' }, { category: 'hard', name: 'Whiski' }, { category: 'soft', name: 'Coke' }, { category: 'soft', name: 'Pepsi' }, { category: 'soft', name: 'Pulp Maid' }, { category: 'soft', name: 'Real Juice' } ]; } </script> </head> <body ng-app = "firstApplication"> <div id = "selectContainer" ng-controller = "selectController as ctrl" layout = "row" ng-cloak> <md-input-container> <label>User</label> <md-select ng-model = "selectedUser"> <md-option ng-value = "user" ng-repeat = "user in users">{{ user.name }}</md-option> </md-select> </md-input-container> <md-input-container> <label>Drinks</label> <md-select ng-model = "drink"> <md-optgroup label = "Hard Drinks"> <md-option ng-value = "drink.name" ng-repeat = "drink in drinks | filter: {category: 'hard' }"> {{drink.name}}</md-option> </md-optgroup> <md-optgroup label = "Soft Drinks"> <md-option ng-value = "drink.name" ng-repeat = "drink in drinks | filter: {category: 'soft' }"> {{drink.name}}</md-option> </md-optgroup> </md-select> </md-input-container> </div> </body> </html>
结果
验证结果。
❮ angular_material_widgets.html