-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: update guides and public APIs for NgModules #961
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,14 @@ some initial config for the SystemJS module loader. | |
### Install Angular Material 2 components | ||
|
||
Now that your project has been created, you can install any Angular Material 2 components you'd like | ||
to use through npm. You can see our [list of published packages here](https://www.npmjs.com/~angular2-material). | ||
to use through npm. You can see our [list of published packages here](https://www.npmjs.com/~angular2-material). | ||
|
||
Note that only packages published under the `@latest` npm tag are officially released. | ||
|
||
```bash | ||
npm install --save @angular2-material/core @angular2-material/button @angular2-material/card | ||
``` | ||
Note: the core module is required as a peer dependency of other components. | ||
(the core module is required as a peer dependency of other components) | ||
|
||
### Add components to vendor bundle | ||
|
||
|
@@ -98,96 +100,43 @@ Now you should be able to import the components normally wherever you'd like to | |
|
||
**src/app/my-project.component.ts** | ||
```ts | ||
import { MD_CARD_DIRECTIVES } from '@angular2-material/card'; | ||
import { MD_BUTTON_DIRECTIVES } from '@angular2-material/button'; | ||
import { MdCardModule } from '@angular2-material/card'; | ||
import { MdButtonModule } from '@angular2-material/button'; | ||
``` | ||
|
||
And don't forget to add the directives to your directives array: | ||
Import the components in your application module: | ||
|
||
**src/app/my-project.component.ts** | ||
**my-app-module.ts** | ||
```ts | ||
directives: [MD_CARD_DIRECTIVES, MD_BUTTON_DIRECTIVES] | ||
@NgModule({ | ||
imports: [MdButtonModule, MdCardModule], | ||
... | ||
}) | ||
``` | ||
|
||
### Sample Angular Material 2 projects | ||
|
||
- [Puppy Love (ng-conf 2016)](https://github.com/kara/puppy-love) - see live demo [here](https://youtu.be/rRiV_b3WsoY?t=4m20s) | ||
- [Puppy Love Mobile (Google IO 2016)](https://github.com/kara/puppy-love-io) | ||
- [Material 2 Sample App](https://github.com/jelbourn/material2-app) | ||
|
||
### Additional steps for using Material components with forms | ||
|
||
If you're using Angular Material 2 version alpha.6 or later, you'll need to upgrade to Angular 2's | ||
new forms module. Here's how: | ||
|
||
- Install the `@angular/forms` package. If you're on Angular RC.4, install version 0.2.0. | ||
|
||
```bash | ||
npm install @angular/forms | ||
``` | ||
|
||
- Change your bootstrap file to disable the old form directives and provide the new form | ||
directives. | ||
|
||
**main.ts** | ||
```ts | ||
import {disableDeprecatedForms, provideForms} from '@angular/forms'; | ||
(the following are slightly out of date now) | ||
- [Puppy Love (ng-conf 2016)](https://github.com/kara/puppy-love) - see live demo [here](https://youtu.be/rRiV_b3WsoY?t=4m20s) | ||
- [Puppy Love Mobile (Google IO 2016)](https://github.com/kara/puppy-love-io) | ||
|
||
bootstrap(MyAppComponent, [ | ||
disableDeprecatedForms(), | ||
provideForms() | ||
]); | ||
``` | ||
|
||
- Import any and all forms symbols - `NgForm`, `Validators`, etc - from `@angular/forms`. | ||
Importing them from `@angular/common` will result in a `No value accessor found` error. | ||
### Additional setup for `md-slide-toggle` and `md-slider`: | ||
The slide-toggle and slider components have a dependency on [HammerJS](http://hammerjs.github.io/). | ||
1) 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. | ||
2) Include the typings for HammerJS in your typescript build. | ||
|
||
- Update your form code to use the new APIs. See more information about the changes in the proposal | ||
doc [here](https://docs.google.com/document/u/1/d/1RIezQqE4aEhBRmArIAS1mRIZtWFf6JxN_7B4meyWK0Y/pub) | ||
and the official documentation [here](https://angular.io/docs/ts/latest/guide/forms.html). | ||
|
||
### Additional steps for `md-icon` setup: | ||
### Additional setup for `md-icon` setup: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additional setup for setup? |
||
|
||
- If you want to use Material Design icons, load the Material Design font in your `index.html`. `md-icon` supports any font icons or svg icons, | ||
so this is only one potential option. | ||
- If you want to use Material Design icons, load the Material Design font in your `index.html`. | ||
`md-icon` supports any font icons or svg icons, so this is only one potential option. | ||
|
||
**src/index.html** | ||
```html | ||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> | ||
``` | ||
|
||
- Include http providers in your `main.ts`: | ||
|
||
**src/main.ts** | ||
```ts | ||
import { HTTP_PROVIDERS } from '@angular/http'; | ||
... | ||
bootstrap(MyAppComponent, [ | ||
HTTP_PROVIDERS | ||
]); | ||
``` | ||
|
||
- Provide the icon registry at or above the component where you're using the icon: | ||
|
||
**src/app/my-project.component.ts** | ||
```ts | ||
import {MdIcon, MdIconRegistry} from '@angular2-material/icon'; | ||
... | ||
directives: [MD_CARD_DIRECTIVES, MD_BUTTON_DIRECTIVES, MdIcon], | ||
providers: [MdIconRegistry] | ||
``` | ||
|
||
- Add the icon package to the list of Material components in your `system-config.ts`: | ||
|
||
**src/system-config.ts** | ||
```ts | ||
// put the names of any of your Material components here | ||
const materialPkgs:string[] = [ | ||
... | ||
'icon' | ||
]; | ||
``` | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,30 +7,17 @@ | |
|
||
### Setup | ||
|
||
`md-menu` relies on the existence of an app-wide `OverlayContainer`. This is the container in which | ||
it will display. You'll need to import this from `@angular2-material/core` and add it to your | ||
providers list on bootstrap. | ||
Impor the MdMenu module. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: |
||
|
||
*main.ts* | ||
*my-app-module.ts* | ||
```ts | ||
import { OverlayContainer } from '@angular2-material/core'; | ||
import {MdMenuModule} from '@angular2-material/menu'; | ||
|
||
bootstrap(AppComponent, [ | ||
OverlayContainer | ||
]); | ||
``` | ||
|
||
You'll also want to import the menu directives and add them to your component's directives array: | ||
|
||
*my-comp.component.ts* | ||
```ts | ||
import {MD_MENU_DIRECTIVES} from '@angular2-material/menu'; | ||
|
||
@Component({ | ||
@NgModule({ | ||
imports: [MdMenuModule], | ||
... | ||
directives: [MD_MENU_DIRECTIVES] | ||
}) | ||
class MyComp {} | ||
export class MyAppModule {} | ||
``` | ||
|
||
### Simple menu | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ export class MdToolbar { | |
|
||
} | ||
|
||
/** @deprecated */ | ||
export const MD_TOOLBAR_DIRECTIVES = [MdToolbar]; | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we include more detailed steps on this for those not super familiar with typescript?