2016-09-13 14:44:43 -07:00
|
|
|
Get started with Angular Material 2 using the Angular CLI.
|
2016-05-25 10:10:26 -07:00
|
|
|
|
2016-09-13 14:44:43 -07:00
|
|
|
## Install the CLI
|
2016-05-25 10:10:26 -07:00
|
|
|
|
|
|
|
|
```bash
|
2016-09-19 19:51:44 +03:00
|
|
|
npm install -g angular-cli
|
2016-05-25 10:10:26 -07:00
|
|
|
```
|
|
|
|
|
|
2016-09-13 14:44:43 -07:00
|
|
|
## Create a new project
|
2016-05-25 10:10:26 -07:00
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
ng new my-project
|
|
|
|
|
```
|
|
|
|
|
|
2016-09-13 14:44:43 -07:00
|
|
|
The new command creates a project with a build system for your Angular app.
|
|
|
|
|
|
2016-09-27 16:58:55 +01:00
|
|
|
## Install Angular Material components
|
2016-05-25 10:10:26 -07:00
|
|
|
|
|
|
|
|
```bash
|
2016-09-27 16:58:55 +01:00
|
|
|
npm install --save @angular/material
|
2016-05-25 10:10:26 -07:00
|
|
|
```
|
|
|
|
|
|
2016-09-27 16:58:55 +01:00
|
|
|
## Import the Angular Material NgModule
|
2016-05-25 10:10:26 -07:00
|
|
|
|
2016-09-13 14:44:43 -07:00
|
|
|
**src/app/app.module.ts**
|
2016-05-25 10:10:26 -07:00
|
|
|
```ts
|
2016-09-27 16:58:55 +01:00
|
|
|
import { MaterialModule } from '@angular/material';
|
2016-09-13 14:44:43 -07:00
|
|
|
// other imports
|
2016-08-09 11:16:08 -07:00
|
|
|
@NgModule({
|
2016-09-27 16:58:55 +01:00
|
|
|
imports: [MaterialModule.forRoot()],
|
2016-08-09 11:16:08 -07:00
|
|
|
...
|
|
|
|
|
})
|
2016-09-27 16:58:55 +01:00
|
|
|
export class PizzaPartyAppModule { }
|
2016-05-25 10:10:26 -07:00
|
|
|
```
|
|
|
|
|
|
2016-10-11 20:48:41 +02:00
|
|
|
## Including core and theme styles:
|
|
|
|
|
This is required to apply all of the core and theme styles to your application.
|
|
|
|
|
See the [theming guide](docs/theming.md) for instructions.
|
2016-07-04 17:07:48 -07:00
|
|
|
|
2016-08-10 17:10:38 -07:00
|
|
|
|
2016-10-11 20:48:41 +02:00
|
|
|
## Additional setup for `md-slide-toggle` and `md-slider`:
|
2016-08-09 11:16:08 -07:00
|
|
|
The slide-toggle and slider components have a dependency on [HammerJS](http://hammerjs.github.io/).
|
2016-07-04 17:07:48 -07:00
|
|
|
|
2016-09-27 16:58:55 +01:00
|
|
|
Add HammerJS to your application via [npm](https://www.npmjs.com/package/hammerjs), a CDN
|
|
|
|
|
(such as the [Google CDN](https://developers.google.com/speed/libraries/#hammerjs)), or served
|
|
|
|
|
directly from your app.
|
2016-07-04 17:07:48 -07:00
|
|
|
|
2016-10-11 20:48:41 +02:00
|
|
|
## [Optional] Using Material Design icons with `md-icon`:
|
2016-05-25 10:10:26 -07:00
|
|
|
|
2016-10-11 20:48:41 +02:00
|
|
|
- If you want to use Material Design icons in addition to Angular Material components,
|
|
|
|
|
load the Material Design font in your `index.html`.
|
|
|
|
|
`md-icon` supports any font icons or svg icons, so this is only one option for an icon source.
|
2016-05-25 10:10:26 -07:00
|
|
|
|
|
|
|
|
**src/index.html**
|
|
|
|
|
```html
|
|
|
|
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
|
|
|
|
```
|
2016-09-27 16:58:55 +01:00
|
|
|
|
2016-10-11 20:48:41 +02:00
|
|
|
## Sample Angular Material 2 projects
|
2016-09-27 16:58:55 +01:00
|
|
|
- [Material 2 Sample App](https://github.com/jelbourn/material2-app)
|
|
|
|
|
- [Angular Connect 2016 Demo](https://github.com/kara/leashed-in)
|