diff --git a/guides/getting-started.md b/guides/getting-started.md index 679676f8cc07..bcbc142137ed 100644 --- a/guides/getting-started.md +++ b/guides/getting-started.md @@ -1,20 +1,55 @@ -For help getting started with a new Angular app, check out the [Angular CLI](https://cli.angular.io/). +For help getting started with a new Angular app, check out the +[Angular CLI](https://cli.angular.io/). For existing apps, follow these steps to begin using Angular Material. -## Step 1: Install Angular Material +## Step 1: Install Angular Material ```bash npm install --save @angular/material ``` -## Step 2: Import the Module - -Add MaterialModule as an import in your app's root NgModule. - +## Step 2: Animations + +Some Material components depend on the Angular animations module in order to be able to do +more advanced transitions. If you want these animations to work in your app, you have to +install the `@angular/animations` module and include the `BrowserAnimationsModule` in your app. + +```bash +npm install --save @angular/animations +``` + ```ts -import { MaterialModule } from '@angular/material'; - +import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; + +@NgModule({ + ... + imports: [BrowserAnimationsModule], + ... +}) +export class PizzaPartyAppModule { } +``` + +If you don't want to add another dependency to your project, you can use the `NoopAnimationsModule`. + +```ts +import {NoopAnimationsModule} from '@angular/platform-browser/animations'; + +@NgModule({ + ... + imports: [NoopAnimationsModule], + ... +}) +export class PizzaPartyAppModule { } +``` + +## Step 3: Import the Module + +Add MaterialModule as an import in your app's root NgModule. + +```ts +import {MaterialModule} from '@angular/material'; + @NgModule({ ... imports: [MaterialModule], @@ -23,9 +58,9 @@ import { MaterialModule } from '@angular/material'; export class PizzaPartyAppModule { } ``` -## Step 3: Include Theming +## Step 4: Include Theming -Including a theme is **required** to apply all of the core and theme styles to your application. +Including a theme is **required** to apply all of the core and theme styles to your application. To get started with a prebuilt theme, include the following in your app's index.html: @@ -35,16 +70,17 @@ To get started with a prebuilt theme, include the following in your app's index. Note that your app's project structure may have a different relative location for your node_modules. -For more information on theming and instructions on how to create a custom theme, see the [theming guide](./theming.md). +For more information on theming and instructions on how to create a custom theme, see the +[theming guide](./theming.md). -## Step 4: Gesture Support +## Step 5: Gesture Support -Some components (`md-slide-toggle`, `md-slider`, `mdTooltip`) rely on +Some components (`md-slide-toggle`, `md-slider`, `mdTooltip`) rely on [HammerJS](http://hammerjs.github.io/) for gestures. In order to get the full feature-set of these components, HammerJS must be loaded into the application. -You can 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 +You can 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. To install via npm, use the following command: @@ -57,22 +93,25 @@ After installing, import it on your app's root module. import 'hammerjs'; ``` -## Step 5 (Optional): Add Material Icons +## Step 6 (Optional): Add Material Icons + +If you want your `md-icon` components to use [Material Icons](https://material.io/icons/), +load the font in your `index.html`. -If you want your `md-icon` components to use [Material Icons](https://material.io/icons/), load the font in your `index.html`. - ```html ``` -For more information on using Material Icons, check out the [Material Icons Guide](https://google.github.io/material-design-icons/). +For more information on using Material Icons, check out the +[Material Icons Guide](https://google.github.io/material-design-icons/). + +Note that `md-icon` has support for any font or svg icons, so using Material Icons is +just one option. -Note that `md-icon` has support for any font or svg icons, so using Material Icons is just one option. - ## Configuring SystemJS -If your project is using SystemJS for module loading, you will need to add `@angular/material` +If your project is using SystemJS for module loading, you will need to add `@angular/material` to the SystemJS configuration: ```js diff --git a/package.json b/package.json index a214163a9cb3..82187c24b8ab 100644 --- a/package.json +++ b/package.json @@ -25,22 +25,23 @@ "node": ">= 5.4.1 < 7" }, "dependencies": { - "@angular/common": "^2.3.0", - "@angular/compiler": "^2.3.0", - "@angular/core": "^2.3.0", - "@angular/forms": "^2.3.0", - "@angular/http": "^2.3.0", - "@angular/platform-browser": "^2.3.0", + "@angular/animations": "^4.0.0-rc.5", + "@angular/common": "^4.0.0-rc.5", + "@angular/compiler": "^4.0.0-rc.5", + "@angular/core": "^4.0.0-rc.5", + "@angular/forms": "^4.0.0-rc.5", + "@angular/http": "^4.0.0-rc.5", + "@angular/platform-browser": "^4.0.0-rc.5", "core-js": "^2.4.1", "rxjs": "^5.0.1", "systemjs": "0.19.43", - "zone.js": "^0.7.2" + "zone.js": "^0.8.4" }, "devDependencies": { - "@angular/compiler-cli": "^2.3.0", - "@angular/platform-browser-dynamic": "^2.3.0", - "@angular/platform-server": "^2.3.0", - "@angular/router": "^3.3.0", + "@angular/compiler-cli": "^4.0.0-rc.5", + "@angular/platform-browser-dynamic": "^4.0.0-rc.5", + "@angular/platform-server": "^4.0.0-rc.5", + "@angular/router": "^4.0.0-rc.5", "@types/chalk": "^0.4.31", "@types/fs-extra": "0.0.37", "@types/glob": "^5.0.30", @@ -106,7 +107,7 @@ "ts-node": "^2.1.0", "tslint": "^4.4.2", "tslint-no-unused-var": "0.0.6", - "typescript": "~2.0.10", + "typescript": "~2.1.6", "uglify-js": "^2.8.7", "web-animations-js": "^2.2.2" } diff --git a/src/demo-app/demo-app-module.ts b/src/demo-app/demo-app-module.ts index 0263eff112fc..31a6f99798eb 100644 --- a/src/demo-app/demo-app-module.ts +++ b/src/demo-app/demo-app-module.ts @@ -2,8 +2,9 @@ import {NgModule, ApplicationRef} from '@angular/core'; import {BrowserModule} from '@angular/platform-browser'; import {HttpModule} from '@angular/http'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {DemoApp, Home} from './demo-app/demo-app'; import {RouterModule} from '@angular/router'; +import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; +import {DemoApp, Home} from './demo-app/demo-app'; import { MaterialModule, OverlayContainer, @@ -44,9 +45,11 @@ import {AutocompleteDemo} from './autocomplete/autocomplete-demo'; import {InputDemo} from './input/input-demo'; import {StyleDemo} from './style/style-demo'; + @NgModule({ imports: [ BrowserModule, + BrowserAnimationsModule, FormsModule, HttpModule, ReactiveFormsModule, diff --git a/src/demo-app/dialog/dialog-demo.html b/src/demo-app/dialog/dialog-demo.html index ec05d8f1ae04..45e7ba5925ca 100644 --- a/src/demo-app/dialog/dialog-demo.html +++ b/src/demo-app/dialog/dialog-demo.html @@ -67,6 +67,6 @@

Other options

Last close result: {{lastCloseResult}}

- + diff --git a/src/demo-app/overlay/overlay-demo.html b/src/demo-app/overlay/overlay-demo.html index 91af08845104..c431cffc15fc 100644 --- a/src/demo-app/overlay/overlay-demo.html +++ b/src/demo-app/overlay/overlay-demo.html @@ -15,16 +15,16 @@ Open menu - + - + diff --git a/src/demo-app/portal/portal-demo.html b/src/demo-app/portal/portal-demo.html index 95d29a441deb..ee17457ba788 100644 --- a/src/demo-app/portal/portal-demo.html +++ b/src/demo-app/portal/portal-demo.html @@ -1,6 +1,6 @@

The portal host is here:

- +
- - +

- Did you hear about this year's Fibonacci Conference?

diff --git a/src/demo-app/system-config.ts b/src/demo-app/system-config.ts index 58a48554a870..2f5ceb6ec1e9 100644 --- a/src/demo-app/system-config.ts +++ b/src/demo-app/system-config.ts @@ -14,7 +14,11 @@ System.config({ '@angular/http': 'vendor/@angular/http/bundles/http.umd.js', '@angular/forms': 'vendor/@angular/forms/bundles/forms.umd.js', '@angular/router': 'vendor/@angular/router/bundles/router.umd.js', + '@angular/animations': 'vendor/@angular/animations/bundles/animations.umd.js', + '@angular/animations/browser': 'vendor/@angular/animations/bundles/animations-browser.umd.js', '@angular/platform-browser': 'vendor/@angular/platform-browser/bundles/platform-browser.umd.js', + '@angular/platform-browser/animations': + 'vendor/@angular/platform-browser/bundles/platform-browser-animations.umd.js', '@angular/platform-browser-dynamic': 'vendor/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', '@angular/material': '@angular/material/bundles/material.umd.js' diff --git a/src/demo-app/tabs/tabs-demo.html b/src/demo-app/tabs/tabs-demo.html index 902009497c67..3e7ead185e3b 100644 --- a/src/demo-app/tabs/tabs-demo.html +++ b/src/demo-app/tabs/tabs-demo.html @@ -48,7 +48,7 @@

Tab Group Demo - Dynamic Tabs

- + {{tab.label}}
{{tab.content}}
@@ -100,7 +100,7 @@

Tab Group Demo - Dynamic Height

- + {{tab.label}}
{{tab.content}}
@@ -146,7 +146,7 @@

Tab Group Demo - Fixed Height

- + {{tab.label}}
{{tab.content}}
@@ -191,7 +191,7 @@

Stretched Tabs

- + {{tab.label}}
{{tab.content}}
@@ -203,7 +203,7 @@

Async Tabs

- + {{tab.label}}
{{tab.content}} diff --git a/src/e2e-app/dialog/dialog-e2e.html b/src/e2e-app/dialog/dialog-e2e.html index b66e8dfd8c51..95b8dc4e8dc6 100644 --- a/src/e2e-app/dialog/dialog-e2e.html +++ b/src/e2e-app/dialog/dialog-e2e.html @@ -2,4 +2,4 @@ - +
my template dialog
diff --git a/src/e2e-app/e2e-app-module.ts b/src/e2e-app/e2e-app-module.ts index 091698206b8f..32b6df2bc5c5 100644 --- a/src/e2e-app/e2e-app-module.ts +++ b/src/e2e-app/e2e-app-module.ts @@ -1,5 +1,6 @@ import {NgModule} from '@angular/core'; -import {BrowserModule, AnimationDriver} from '@angular/platform-browser'; +import {BrowserModule} from '@angular/platform-browser'; +import {NoopAnimationsModule} from '@angular/platform-browser/animations'; import {RouterModule} from '@angular/router'; import {SimpleCheckboxes} from './checkbox/checkbox-e2e'; import {E2EApp, Home} from './e2e-app/e2e-app'; @@ -23,6 +24,7 @@ import {SlideToggleE2E} from './slide-toggle/slide-toggle-e2e'; BrowserModule, RouterModule.forRoot(E2E_APP_ROUTES), MaterialModule.forRoot(), + NoopAnimationsModule, ], declarations: [ E2EApp, @@ -45,7 +47,6 @@ import {SlideToggleE2E} from './slide-toggle/slide-toggle-e2e'; ], bootstrap: [E2EApp], providers: [ - {provide: AnimationDriver, useValue: AnimationDriver.NOOP}, {provide: OverlayContainer, useClass: FullscreenOverlayContainer} ], entryComponents: [TestDialog, TestDialogFullScreen] diff --git a/src/e2e-app/system-config.ts b/src/e2e-app/system-config.ts index e5615524cb8e..c56d9a84851a 100644 --- a/src/e2e-app/system-config.ts +++ b/src/e2e-app/system-config.ts @@ -14,6 +14,10 @@ System.config({ '@angular/http': 'vendor/@angular/http/bundles/http.umd.js', '@angular/forms': 'vendor/@angular/forms/bundles/forms.umd.js', '@angular/router': 'vendor/@angular/router/bundles/router.umd.js', + '@angular/animations': 'vendor/@angular/animations/bundles/animations.umd.js', + '@angular/animations/browser': 'vendor/@angular/animations/bundles/animations-browser.umd.js', + '@angular/platform-browser/animations': + 'vendor/@angular/platform-browser/bundles/platform-browser-animations.umd.js', '@angular/platform-browser': 'vendor/@angular/platform-browser/bundles/platform-browser.umd.js', '@angular/platform-browser/testing': 'vendor/@angular/platform-browser/bundles/platform-browser-testing.umd.js', diff --git a/src/e2e-app/tabs/tabs-e2e.html b/src/e2e-app/tabs/tabs-e2e.html index 20e03126c0a5..9e9431af0cc0 100644 --- a/src/e2e-app/tabs/tabs-e2e.html +++ b/src/e2e-app/tabs/tabs-e2e.html @@ -1,15 +1,15 @@
- + One First tab's content - + Two Second tab's content - + Three Third tab's content diff --git a/src/lib/autocomplete/autocomplete.html b/src/lib/autocomplete/autocomplete.html index cd94ceeb7340..41227961fe5c 100644 --- a/src/lib/autocomplete/autocomplete.html +++ b/src/lib/autocomplete/autocomplete.html @@ -1,5 +1,5 @@ - \ No newline at end of file + diff --git a/src/lib/checkbox/checkbox.spec.ts b/src/lib/checkbox/checkbox.spec.ts index 4f75c88051b0..b5a1b5a4f053 100644 --- a/src/lib/checkbox/checkbox.spec.ts +++ b/src/lib/checkbox/checkbox.spec.ts @@ -113,7 +113,7 @@ describe('MdCheckbox', () => { expect(inputElement.indeterminate).toBe(false); }); - it('should set indeterminate to false when set checked', () => { + it('should set indeterminate to false when set checked', async(() => { testComponent.isIndeterminate = true; fixture.detectChanges(); @@ -124,27 +124,34 @@ describe('MdCheckbox', () => { testComponent.isChecked = true; fixture.detectChanges(); - expect(checkboxInstance.checked).toBe(true); - expect(inputElement.indeterminate).toBe(false); - expect(inputElement.checked).toBe(true); - expect(testComponent.isIndeterminate).toBe(false); + fixture.whenStable().then(() => { + fixture.detectChanges(); + expect(checkboxInstance.checked).toBe(true); + expect(inputElement.indeterminate).toBe(false); + expect(inputElement.checked).toBe(true); + expect(testComponent.isIndeterminate).toBe(false); - testComponent.isIndeterminate = true; - fixture.detectChanges(); + testComponent.isIndeterminate = true; + fixture.detectChanges(); - expect(checkboxInstance.indeterminate).toBe(true); - expect(inputElement.indeterminate).toBe(true); - expect(inputElement.checked).toBe(true); - expect(testComponent.isIndeterminate).toBe(true); + expect(checkboxInstance.indeterminate).toBe(true); + expect(inputElement.indeterminate).toBe(true); + expect(inputElement.checked).toBe(true); + expect(testComponent.isIndeterminate).toBe(true); - testComponent.isChecked = false; - fixture.detectChanges(); + testComponent.isChecked = false; + fixture.detectChanges(); - expect(checkboxInstance.checked).toBe(false); - expect(inputElement.indeterminate).toBe(false); - expect(inputElement.checked).toBe(false); - expect(testComponent.isIndeterminate).toBe(false); - }); + fixture.whenStable().then(() => { + fixture.detectChanges(); + expect(checkboxInstance.checked).toBe(false); + expect(inputElement.indeterminate).toBe(false); + expect(inputElement.checked).toBe(false); + expect(testComponent.isIndeterminate).toBe(false); + }); + }); + + })); it('should change native element checked when check programmatically', () => { expect(inputElement.checked).toBe(false); @@ -169,7 +176,7 @@ describe('MdCheckbox', () => { expect(checkboxInstance.checked).toBe(false); }); - it('should change from indeterminate to checked on click', () => { + it('should change from indeterminate to checked on click', async(() => { testComponent.isChecked = false; testComponent.isIndeterminate = true; fixture.detectChanges(); @@ -179,15 +186,17 @@ describe('MdCheckbox', () => { checkboxInstance._onInputClick({stopPropagation: () => {}}); - expect(checkboxInstance.checked).toBe(true); - expect(checkboxInstance.indeterminate).toBe(false); + fixture.whenStable().then(() => { + expect(checkboxInstance.checked).toBe(true); + expect(checkboxInstance.indeterminate).toBe(false); - checkboxInstance._onInputClick({stopPropagation: () => {}}); - fixture.detectChanges(); + checkboxInstance._onInputClick({stopPropagation: () => {}}); + fixture.detectChanges(); - expect(checkboxInstance.checked).toBe(false); - expect(checkboxInstance.indeterminate).toBe(false); - }); + expect(checkboxInstance.checked).toBe(false); + expect(checkboxInstance.indeterminate).toBe(false); + }); + })); it('should add and remove disabled state', () => { expect(checkboxInstance.disabled).toBe(false); @@ -219,16 +228,18 @@ describe('MdCheckbox', () => { expect(checkboxInstance.checked).toBe(false); }); - it('should overwrite indeterminate state when checked is re-set', () => { + it('should overwrite indeterminate state when checked is re-set', async(() => { testComponent.isIndeterminate = true; fixture.detectChanges(); testComponent.isChecked = true; fixture.detectChanges(); - expect(checkboxInstance.checked).toBe(true); - expect(checkboxInstance.indeterminate).toBe(false); - }); + fixture.whenStable().then(() => { + expect(checkboxInstance.checked).toBe(true); + expect(checkboxInstance.indeterminate).toBe(false); + }); + })); it('should preserve the user-provided id', () => { expect(checkboxNativeElement.id).toBe('simple-check'); diff --git a/src/lib/checkbox/checkbox.ts b/src/lib/checkbox/checkbox.ts index 8ff44319a258..5b36e586c99c 100644 --- a/src/lib/checkbox/checkbox.ts +++ b/src/lib/checkbox/checkbox.ts @@ -225,8 +225,10 @@ export class MdCheckbox implements ControlValueAccessor, AfterViewInit, OnDestro set checked(checked: boolean) { if (checked != this.checked) { if (this._indeterminate) { - this._indeterminate = false; - this.indeterminateChange.emit(this._indeterminate); + Promise.resolve().then(() => { + this._indeterminate = false; + this.indeterminateChange.emit(this._indeterminate); + }); } this._checked = checked; this._changeDetectorRef.markForCheck(); diff --git a/src/lib/core/overlay/overlay-directives.spec.ts b/src/lib/core/overlay/overlay-directives.spec.ts index 26368a112a7b..3af7f42e7911 100644 --- a/src/lib/core/overlay/overlay-directives.spec.ts +++ b/src/lib/core/overlay/overlay-directives.spec.ts @@ -268,14 +268,14 @@ describe('Overlay directives', () => { @Component({ template: ` - `, + `, }) class ConnectedOverlayDirectiveTest { isOpen = false; diff --git a/src/lib/core/overlay/overlay.spec.ts b/src/lib/core/overlay/overlay.spec.ts index 328809e4d272..46ebcb18454b 100644 --- a/src/lib/core/overlay/overlay.spec.ts +++ b/src/lib/core/overlay/overlay.spec.ts @@ -307,7 +307,7 @@ class PizzaMsg { } /** Test-bed component that contains a TempatePortal and an ElementRef. */ -@Component({template: ``}) +@Component({template: `Cake`}) class TestComponentWithTemplatePortals { @ViewChild(TemplatePortalDirective) templatePortal: TemplatePortalDirective; diff --git a/src/lib/core/portal/README.md b/src/lib/core/portal/README.md index c8c1b3b5cfb1..214823de6b3e 100644 --- a/src/lib/core/portal/README.md +++ b/src/lib/core/portal/README.md @@ -34,13 +34,13 @@ be built upon. ##### `TemplatePortalDirective` -Used to get a portal from a `