Angular Material
Angular Material
Angular Material
#angular-
material
Table of Contents
About 1
Remarks 2
Versions 2
Examples 4
Installation or Setup 4
Master (HEAD) 7
Chapter 2: md-button 9
Examples 9
Types of 9
Standard button 11
Chapter 3: md-card 13
Introduction 13
Remarks 13
Examples 13
Chapter 4: md-chips 15
Examples 15
Static chips 15
Setting the delay to select a new chip before refocusing on the input (1.1.2) 15
Credits 17
About
You can share this PDF with anyone you feel could benefit from it, downloaded the latest version
from: angular-material
It is an unofficial and free angular-material ebook created for educational purposes. All the content
is extracted from Stack Overflow Documentation, which is written by many hardworking individuals
at Stack Overflow. It is neither affiliated with Stack Overflow nor official angular-material.
The content is released under Creative Commons BY-SA, and the list of contributors to each
chapter are provided in the credits section at the end of this book. Images may be copyright of
their respective owners unless otherwise specified. All trademarks and registered trademarks are
the property of their respective company owners.
Use the content presented in this book at your own risk; it is not guaranteed to be correct nor
accurate, please send your feedback and corrections to [email protected]
https://riptutorial.com/ 1
Chapter 1: Getting started with angular-
material
Remarks
Angular Material is an UI component framework that allows you to produce single-page-application
using a set of predefined components and directives.
Versions
1.1.4 2017-04-20
1.1.3 2017-01-31
1.1.2 2017-01-05
1.1.1 2016-09-01
1.1.0 2016-08-14
1.1.0-rc5 2016-06-03
1.1.0-rc4 2016-04-15
1.1.0-rc2 2016-03-30
1.1.0-rc1 2016-03-09
1.0.9 2016-05-19
1.0.8 2016-04-28
1.0.7 2016-04-01
1.0.6 2016-02-29
1.0.5 2016-02-04
1.0.4 2016-01-28
1.0.3 2016-01-21
1.0.2 2016-01-14
1.0.1 2015-12-17
https://riptutorial.com/ 2
Version Release Date
1.0.0 2015-12-14
1.0.0-rc7 2015-12-08
1.0.0-rc6 2015-12-02
1.0.0-rc5 2015-11-25
1.0.0-rc4 2015-11-13
1.0.0-rc3 2015-11-06
1.0.0-rc2 2015-10-29
1.0.0-rc1 2015-10-21
0.11.4 2015-10-13
0.11.3 2015-10-12
0.11.2 2015-10-01
0.11.1 2015-09-25
0.11.0 2015-09-08
0.11.0-rc2 2015-09-03
0.11.0-rc1 2015-09-01
0.10.1 2015-08-11
0.10.0 2015-06-15
0.9.8 2015-06-08
0.9.8-rc1 2015-06-05
0.9.7 2015-06-01
0.9.5 2015-05-28
0.9.4 2015-05-15
0.9.3 2015-05-14
0.9.0 2015-05-04
0.9.0-rc3 2015-04-28
https://riptutorial.com/ 3
Version Release Date
0.9.0-rc2 2015-04-20
0.9.0-rc1 2015-04-14
0.8.3 2015-03-03
0.8.2 2015-02-27
0.8.1 2015-02-24
0.8.0 2015-02-23
0.7.1 2015-01-30
0.7.0 2015-01-24
0.7.0-rc3 2015-01-14
0.7.0-rc2 2015-01-08
0.7.0-rc1 2014-12-19
0.6.1 2014-12-08
0.6.0-rc3 2014-11-26
0.6.0-rc2 2014-11-24
0.6.0-rc1 2014-11-18
0.5.1 2014-10-31
0.4.2 2014-10-16
0.4.1 2014-10-15
0.4.0 2014-10-06
0.0.3 2014-09-19
Examples
Installation or Setup
https://riptutorial.com/ 4
npm install angular-material --save
bower
jspm
From Cloud
</body>
</html>
https://riptutorial.com/ 5
Setting up with the CDN
<link rel="stylesheet"
href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.1/angular-material.min.css">
Required dependencies:
• angular
• angular-aria
• angular-animate
• angular-messages
Link: https://material.angularjs.org/latest/getting-started
index.html
<!DOCTYPE html>
<html ng-app="angularMaterial">
<head>
<link
rel="stylesheet"href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.1/angular-
material.min.css">
<!-- Angular Material requires Angular.js Libraries -->
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-
animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-
aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-
messages.min.js"></script>
https://riptutorial.com/ 6
</html>
app.js
Master (HEAD)
index.html:
<html ng-app="masterAngularMaterial">
<head>
<!-- This is important (meta) -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Angular and other dependencies -->
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular-
animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular-
aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular-
messages.min.js"></script>
<!-- Angular Material -->
<script src="https://cdn.rawgit.com/angular/bower-material/master/angular-
material.min.js"></script>
<link href="https://cdn.rawgit.com/angular/bower-material/master/angular-
material.min.css" rel="stylesheet">
<script src="/path/to/app.js"></script>
</head>
<body>
<md-content ng-controller="SomeController">
{{content}}
</md-content>
</body>
</html>
app.js:
https://riptutorial.com/ 7
material/topic/2527/getting-started-with-angular-material
https://riptutorial.com/ 8
Chapter 2: md-button
Examples
Types of
Make sure you link the Angular and Angular Material libraries!
index.html:
<html ng-app="mdButtonApp">
<head>
<!-- Import Angular -->
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-
animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-
aria.min.js"></script>
<!-- Angular Material -->
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.5.8/angular-
material.min.js"></script>
<link href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.1/angular-
material.min.css" rel="stylesheet">
<script src="app.js"></script>
</head>
<body>
<md-content ng-controller="mdButtonController">
<!-- Normal `md-button` -->
<md-button>Normal</md-button>
<md-button class="md-primary">{{text}}</md-button>
<md-button class="md-accent">{{text}}</md-button>
<md-button class="md-warn" ng-href="{{link}}">Google</md-button>
<md-button class="md-raised" ng-click="goToLink('http://example.com')">Link</md-
button>
<md-button class="md-cornered md-primary md-hue-1">{{text}}</md-button>
<md-button class="md-accent md-hue-2">Some Button</md-button>
<md-button class="md-warn md-hue-3" ng-href="{{link}}">{{text}}</md-button>
</md-content>
</body>
</html>
app.js:
https://riptutorial.com/ 9
Creating an icon button
This example will be using the class md-icon-button, which must be applied to <md-button> in order
to get an icon button.
index.html:
<html ng-app="mdIconButtonApp">
<head>
<!-- Import Angular -->
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular-
animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular-
aria.min.js"></script>
<!-- Angular Material -->
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.5.11/angular-
material.min.js"></script>
<link href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.4/angular-
material.min.css" rel="stylesheet">
<!-- Material Icons -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">
<!-- Roboto -->
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<!-- app.js -->
<script src="app.js"></script>
<style>
body {
font-family: Roboto, sans-serif;
}
</style>
</head>
<body>
<md-content ng-controller="mdIconButtonController">
<!--
Normal `md-button`
Note that it is recommended to add a `aria-label` to `md-icon-button` for
accessibility purposes.
-->
<md-button class="md-icon-button" aria-label="{{ariaLabel}}">
<md-icon class="material-icons">menu</md-icon>
</md-button>
<md-button class="md-primary md-icon-button" aria-label="{{ariaLabel}}">
<md-icon class="material-icons">menu</md-icon>
<md-tooltip>This is a tooltip!</md-tooltip>
</md-button>
<md-button class="md-accent md-icon-button md-fab" ng-
click="goToLink('https://github.com/android')" aria-label="Go To Android">
https://riptutorial.com/ 10
<md-icon class="material-icons">android</md-icon>
</md-button>
<md-button class="md-warn md-icon-button" ng-href="{{link}}" aria-
label="{{ariaLabel}}">
<md-icon class="material-icons">{{icon}}</md-icon>
</md-button>
<md-button class="md-raised md-icon-button" ng-
click="goToLink('http://example.com')">
<!-- Note that you must have $mdIconProvider for this -->
<md-icon md-svg-icon="link"></md-icon>
</md-button>
<md-button class="md-cornered md-primary md-hue-1 md-icon-button" aria-
label="{{ariaLabel}}">
<!-- You can also use the source of SVG -->
<md-icon md-svg-src="/path/to/more.svg"></md-icon>
</md-button>
<md-button class="md-accent md-hue-2" aria-label="{{ariaLabel}}">
<md-icon class="material-icons">g-translate</md-icon>
</md-button>
<md-button class="md-warn md-hue-3 md-icon-button" ng-href="{{link}}" aria-
label="Link">
<md-icon md-svg-icon="copyright"></md-icon>
</md-button>
</md-content>
</body>
</html>
app.js:
Standard button
So, well, how on earth do you create a <md-button>, you may ask? All you have to do is to enter a
<md-button>, along with your text for the button in it.
index.html:
<div ng-app="MdButtonApp">
<md-content ng-controller="Controller">
https://riptutorial.com/ 11
<h2 class="md-title">Simple <code>md-button</code></h2>
<md-button>Some button</md-button>
</md-content>
</div>
app.js:
Codepen Demo
https://riptutorial.com/ 12
Chapter 3: md-card
Introduction
This topic is about how to create a <md-card>, which you can use for blog posts and other things.
Remarks
API Documentation: mdCard
Examples
Basic card with header
<md-card>
<md-card-header>
<md-card-header-text>
<span class="md-title">This will be the title</span>
<span class="md-subhead">Here goes the (smaller, lighter) sub-header</span>
</md-card-header-text>
</md-card-header>
<md-card-content>
<p>
Your content goes here!
</p>
</md-card-content>
</md-card>
If you want your card to include buttons, use the md-card-actions directive. Buttons can also be
formatted differently for icon-only buttons. Search for icons at here if you're using Google's
Material Icons.
<md-card>
<!--header-->
<md-card-content>
<p>
Your content goes here!
</p>
</md-card-content>
<md-card-actions>
<md-button>Save</md-button>
<md-button>Cancel</md-button>
<md-card-icon-actions>
<md-button aria-label="icon" class="md-icon-button">
<md-icon>help</md-icon>
</md-button>
</md-card-icon-actions>
</md-card-actions>
https://riptutorial.com/ 13
</md-card>
If you want an avatar to appear on the card, use the <md-card-avatar> directive, which must be
placed within the <md-card-header> directive. The <md-card-avatar> directive accepts an <img /> tag.
Optional: .md-user-avatar, which makes the <img /> tag have a circle look.
index.html:
<md-card>
<md-card-header>
<!--Avatar-->
<md-card-avatar>
<img src="/path/to/avatar.svg" class="md-user-avatar"/>
</md-card-avatar>
<!--Header text-->
<md-card-header-text>
<span class="md-title">Lorem</span>
<span class="md-subhead">Ipsum</span>
</md-card-header-text>
</md-card-header>
<!--Card image-->
<img src="/path/to/cardimage.svg" class="md-card-image" alt="Card Image">
<!--Card title-->
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card header</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus posuere et risus
sed finibus. Nunc vestibulum sagittis enim ut sagittis.</p>
</md-card-content>
</md-card>
https://riptutorial.com/ 14
Chapter 4: md-chips
Examples
Static chips
NOTE: Static chips cannot be selected, removed or edited, and are not part of any model. If no ng-
model is provided, there are no input elements in <md-chips>.
index.html:
<md-content ng-controller="ChipController">
<md-chips>
<md-chip>Test</md-chip>
<md-chip>Another chip</md-chip>
<md-chip>{{chip}}</md-chip>
</md-chips>
app.js:
Setting the delay to select a new chip before refocusing on the input (≥1.1.2)
1.1.2
From versions 1.1.2 and up, you can set the delay to select a new chip before refocusing on the
input.
Example:
According to angular-material:
This is necessary for keyboard accessibility for screen readers. It defaults to 300ms
and any number less than 300 can cause issues with screen readers (particularly
JAWS and sometimes NVDA).
https://riptutorial.com/ 15
Read md-chips online: https://riptutorial.com/angular-material/topic/9306/md-chips
https://riptutorial.com/ 16
Credits
S.
Chapters Contributors
No
Getting started with Alexander Romero, Community, Edric, H.T, Sender, troig,
1
angular-material user3554664
2 md-button Edric
4 md-chips Edric
https://riptutorial.com/ 17