- 角度材质教程
- 角材料 - 主页
- 角度材料 - 概述
- 环境设置
- 角度材质 - 自动完成
- 角材料 - 底板
- 角度材料 - 卡片
- Angular 材质 - 小部件
- Angular 材质 - 布局
- 角度材质 - 输入
- 角度材质 - 图标
- 角度材质 - 网格
- 角度材质 - SideNav
- Angular Material - Fab 快速拨号
- 角度材料 - 副标题
- 角度材质 - 滑动
- 角材料 - 开关
- Angular 材质 - 主题
- 角度材料 - 吐司
- 角度材料 - 版式
- 角度材质 - 虚拟重复
- 角材质 - WhiteFrame
- 角度材质有用资源
- 角度材质 - 快速指南
- 角度材料 - 有用的资源
- 角度材料 - 讨论
角度材质 - 图标
md -icon是一个 Angular 指令,是一个在应用程序中显示基于矢量的图标的组件。除了使用 Google Material 图标之外,它还支持图标字体和 SVG 图标。
属性
下表列出了md-icon的参数和不同属性的说明。
| 先生编号 | 参数及说明 |
|---|---|
| 1 | * md-字体图标 这是与 font-face 关联的 CSS 图标的字符串名称,它将用于渲染图标。需要预加载字体和命名的 CSS 样式。 |
| 2 | * md-字体集 这是与字体库关联的 CSS 样式名称,它将被指定为字体图标连字的类。该值也可以是用于查找类名的别名;内部使用 $mdIconProvider.fontSet(<alias>) 来确定样式名称。 |
| 3 | * md-svg-src 这是用于加载、缓存和显示外部 SVG 的字符串 URL(或表达式)。 |
| 4 | * md-svg-图标 这是用于从内部缓存查找图标的字符串名称;也可以使用内插字符串或表达式。特定的集名称可以通过语法 <集名称>:<图标名称> 来使用。要使用图标集,开发人员需要使用 $mdIconProvider 服务预先注册图标集。 |
| 5 | 咏叹调标签 此标签图标用于辅助功能。如果提供空字符串,则图标将在 aria-hidden = "true" 的辅助功能层中隐藏。如果图标上没有 aria-label ,父元素上也没有标签,则会在控制台中记录一条警告。 |
| 6 | 替代 此标签图标用于辅助功能。如果提供空字符串,则图标将在 aria-hidden = "true" 的辅助功能层中隐藏。如果图标上没有 alt,父元素上也没有标签,则控制台将记录一条警告。 |
例子
以下示例显示了 md-icons 指令的使用以及图标的使用。
am_icons.htm
<html lang = "en">
<head>
<link rel = "stylesheet"
href = "https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css">
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-messages.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js"></script>
<link rel = "stylesheet" href = "https://fonts.googleapis.com/icon?family=Material+Icons">
<style>
.iconDemo .glyph {
border-bottom: 1px dotted #ccc;
padding: 10px 0 20px;
margin-bottom: 20px;
}
.iconDemo .preview-glyphs {
display: flex;
flex-direction: row;
}
.iconDemo .step {
flex-grow: 1;
line-height: 0.5;
}
.iconDemo .material-icons.md-18 {
font-size: 18px;
}
.iconDemo .material-icons.md-24 {
font-size: 24px;
}
.iconDemo .material-icons.md-36 {
font-size: 36px;
}
.iconDemo .material-icons.md-48 {
font-size: 48px;
}
.iconDemo .material-icons.md-dark {
color: rgba(0, 0, 0, 0.54);
}
.iconDemo .material-icons.md-dark.md-inactive {
color: rgba(0, 0, 0, 0.26);
}
.iconDemo .material-icons.md-light {
color: white;
}
.iconDemo .material-icons.md-light.md-inactive {
color: rgba(255, 255, 255, 0.3);
}
</style>
<script language = "javascript">
angular
.module('firstApplication', ['ngMaterial'])
.controller('iconController', iconController);
function iconController ($scope) {
var iconData = [
{name: 'accessibility' , color: "#777" },
{name: 'question_answer', color: "rgb(89, 226, 168)" },
{name: 'backup' , color: "#A00" },
{name: 'email' , color: "#00A" }
];
$scope.fonts = [].concat(iconData);
$scope.sizes = [
{size:"md-18",padding:0},
{size:"md-24",padding:2},
{size:"md-36",padding:6},
{size:"md-48",padding:10}
];
}
</script>
</head>
<body ng-app = "firstApplication">
<div id = "iconContainer" class = "iconDemo"
ng-controller = "iconController as ctrl" ng-cloak>
<div class = "glyph" ng-repeat = "font in fonts" layout = "row">
<div ng-repeat = "it in sizes" flex layout-align = "center center"
style = "text-align: center;" layout = "column">
<div flex></div>
<div class = "preview-glyphs">
<md-icon ng-style = "{color: font.color}"
aria-label = "{{ font.name }}"
class = "material-icons step"
ng-class = "it.size">
{{ font.name }}
</md-icon>
</div>
</div>
</div>
</div>
</body>
</html>
结果
验证结果。