1
- For help getting started with a new Angular app, check out the [ Angular CLI] ( https://cli.angular.io/ ) .
1
+ For help getting started with a new Angular app, check out the
2
+ [ Angular CLI] ( https://cli.angular.io/ ) .
2
3
3
4
For existing apps, follow these steps to begin using Angular Material.
4
5
5
- ## Step 1: Install Angular Material
6
+ ## Step 1: Install Angular Material
6
7
7
8
``` bash
8
9
npm install --save @angular/material
9
10
```
10
11
11
- ## Step 2: Import the Module
12
-
13
- Add MaterialModule as an import in your app's root NgModule.
14
-
12
+ ## Step 2: Animations
13
+
14
+ Some Material components depend on the Angular animations module in order to be able to do
15
+ more advanced transitions. If you want these animations to work in your app, you have to
16
+ install the ` @angular/animations ` module and include the ` BrowserAnimationsModule ` in your app.
17
+
18
+ ``` bash
19
+ npm install --save @angular/animations
20
+ ```
21
+
15
22
``` ts
16
- import { MaterialModule } from ' @angular/material' ;
17
-
23
+ import {BrowserAnimationsModule } from ' @angular/platform-browser/animations' ;
24
+
25
+ @NgModule ({
26
+ ...
27
+ imports : [BrowserAnimationsModule ],
28
+ ...
29
+ })
30
+ export class PizzaPartyAppModule { }
31
+ ```
32
+
33
+ If you don't want to add another dependency to your project, you can use the ` NoopAnimationsModule ` .
34
+
35
+ ``` ts
36
+ import {NoopAnimationsModule } from ' @angular/platform-browser/animations' ;
37
+
38
+ @NgModule ({
39
+ ...
40
+ imports : [NoopAnimationsModule ],
41
+ ...
42
+ })
43
+ export class PizzaPartyAppModule { }
44
+ ```
45
+
46
+ ## Step 3: Import the Module
47
+
48
+ Add MaterialModule as an import in your app's root NgModule.
49
+
50
+ ``` ts
51
+ import {MaterialModule } from ' @angular/material' ;
52
+
18
53
@NgModule ({
19
54
...
20
55
imports : [MaterialModule ],
@@ -23,9 +58,9 @@ import { MaterialModule } from '@angular/material';
23
58
export class PizzaPartyAppModule { }
24
59
```
25
60
26
- ## Step 3 : Include Theming
61
+ ## Step 4 : Include Theming
27
62
28
- Including a theme is ** required** to apply all of the core and theme styles to your application.
63
+ Including a theme is ** required** to apply all of the core and theme styles to your application.
29
64
30
65
To get started with a prebuilt theme, include the following in your app's index.html:
31
66
@@ -35,16 +70,17 @@ To get started with a prebuilt theme, include the following in your app's index.
35
70
36
71
Note that your app's project structure may have a different relative location for your node_modules.
37
72
38
- For more information on theming and instructions on how to create a custom theme, see the [ theming guide] ( ./theming.md ) .
73
+ For more information on theming and instructions on how to create a custom theme, see the
74
+ [ theming guide] ( ./theming.md ) .
39
75
40
- ## Step 4 : Gesture Support
76
+ ## Step 5 : Gesture Support
41
77
42
- Some components (` md-slide-toggle ` , ` md-slider ` , ` mdTooltip ` ) rely on
78
+ Some components (` md-slide-toggle ` , ` md-slider ` , ` mdTooltip ` ) rely on
43
79
[ HammerJS] ( http://hammerjs.github.io/ ) for gestures. In order to get the full feature-set of these
44
80
components, HammerJS must be loaded into the application.
45
81
46
- You can add HammerJS to your application via [ npm] ( https://www.npmjs.com/package/hammerjs ) , a CDN
47
- (such as the [ Google CDN] ( https://developers.google.com/speed/libraries/#hammerjs ) ), or served
82
+ You can add HammerJS to your application via [ npm] ( https://www.npmjs.com/package/hammerjs ) , a CDN
83
+ (such as the [ Google CDN] ( https://developers.google.com/speed/libraries/#hammerjs ) ), or served
48
84
directly from your app.
49
85
50
86
To install via npm, use the following command:
@@ -57,22 +93,25 @@ After installing, import it on your app's root module.
57
93
import ' hammerjs' ;
58
94
```
59
95
60
- ## Step 5 (Optional): Add Material Icons
96
+ ## Step 6 (Optional): Add Material Icons
97
+
98
+ If you want your ` md-icon ` components to use [ Material Icons] ( https://material.io/icons/ ) ,
99
+ load the font in your ` index.html ` .
61
100
62
- If you want your ` md-icon ` components to use [ Material Icons] ( https://material.io/icons/ ) , load the font in your ` index.html ` .
63
-
64
101
``` html
65
102
<link href =" https://fonts.googleapis.com/icon?family=Material+Icons" rel =" stylesheet" >
66
103
```
67
104
68
- For more information on using Material Icons, check out the [ Material Icons Guide] ( https://google.github.io/material-design-icons/ ) .
105
+ For more information on using Material Icons, check out the
106
+ [ Material Icons Guide] ( https://google.github.io/material-design-icons/ ) .
107
+
108
+ Note that ` md-icon ` has support for any font or svg icons, so using Material Icons is
109
+ just one option.
69
110
70
- Note that ` md-icon ` has support for any font or svg icons, so using Material Icons is just one option.
71
-
72
111
73
112
## Configuring SystemJS
74
113
75
- If your project is using SystemJS for module loading, you will need to add ` @angular/material `
114
+ If your project is using SystemJS for module loading, you will need to add ` @angular/material `
76
115
to the SystemJS configuration:
77
116
78
117
``` js
0 commit comments