Skip to content
This repository has been archived by the owner on Feb 2, 2019. It is now read-only.

Commit

Permalink
feat(examples): focus input when sidenav is shown
Browse files Browse the repository at this point in the history
 - re-export the outputs from MdBackdrop so that Angular knows about them.
  • Loading branch information
justindujardin committed Jan 31, 2016
1 parent 5d1ce24 commit dff7050
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions examples/components/sidenav/basic_usage.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ <h1 class="md-toolbar-tools">Sidenav Left</h1>

</md-content>

<md-sidenav name="right" align="right" layout="column">
<md-sidenav name="right" align="right" layout="column" (onShown)="input.focus()">
<md-toolbar class="md-theme-light">
<h1 class="md-toolbar-tools">Sidenav Right</h1>
</md-toolbar>
<md-content layout-padding>
<form>
<md-input-container class="md-block">
<label for="testInput">Test input</label>
<input type="text" id="testInput" md-input
<input type="text" id="testInput" md-input #input
[(value)]="data" md-autofocus>
</md-input-container>
</form>
Expand Down
12 changes: 11 additions & 1 deletion ng2-material/components/sidenav/sidenav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import {
Optional,
SkipSelf,
Host,
ApplicationRef
ApplicationRef,
Output,
EventEmitter
} from "angular2/core";
import {MdBackdrop} from "../backdrop/backdrop";
import {DOM} from "angular2/src/platform/dom/dom_adapter";
Expand Down Expand Up @@ -75,6 +77,14 @@ export class MdSidenav extends MdBackdrop implements OnInit, OnDestroy {
@Input()
name: string = 'default';

// TODO(jd): sucks that we have to re-export the outputs from a child class, but
// without this you cannot bind to the events in a template. :sob:
@Output() onHiding: EventEmitter<MdSidenav>;
@Output() onHidden: EventEmitter<MdSidenav>;
@Output() onShowing: EventEmitter<MdSidenav>;
@Output() onShown: EventEmitter<MdSidenav>;


@Input()
set align(value: string) {
this._align = value === SidenavAlignment.RIGHT ? SidenavAlignment.RIGHT : SidenavAlignment.LEFT;
Expand Down

0 comments on commit dff7050

Please sign in to comment.