From fc6fc251ffcb3387c6570087dfbdb3ac1a9a9377 Mon Sep 17 00:00:00 2001 From: Kara Date: Wed, 4 Jan 2017 17:33:01 -0800 Subject: [PATCH] docs(select): add basic readme (#2438) Closes #2148 --- src/lib/select/OVERVIEW.md | 43 +++++++++++++++++++++--- src/lib/select/README.md | 69 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 106 insertions(+), 6 deletions(-) diff --git a/src/lib/select/OVERVIEW.md b/src/lib/select/OVERVIEW.md index 27aee5f25dd..8ff4d404f6b 100644 --- a/src/lib/select/OVERVIEW.md +++ b/src/lib/select/OVERVIEW.md @@ -1,8 +1,43 @@ `` is a form control for selecting a value from a set of options, similar to the native -`` element. You can read more about selects in the +[Material Design spec](https://material.google.com/components/menus.html). -### Use with `@angular/forms` -`` is compatible with `@angular/forms` and supports both `FormsModule` -and `ReactiveFormsModule`. +### Simple select + +In your template, create an `md-select` element. For each option you'd like in your select, add an +`md-option` tag. Note that you can disable items by adding the `disabled` boolean attribute or +binding to it. + +*my-comp.html* +```html + + {{ state.name }} + +``` + +### Getting and setting the select value + +The select component is set up as a custom value accessor, so you can manipulate the select's value using +any of the form directives from the core `FormsModule` or `ReactiveFormsModule`: `ngModel`, `formControl`, etc. + +*my-comp.html* +```html + + {{ state.name }} + +``` + +*my-comp.ts* +```ts +class MyComp { + myState = 'AZ'; + states = [{code: 'AL', name: 'Alabama'}...]; +} +``` + +#### Keyboard interaction: +- DOWN_ARROW: Focus next option +- UP_ARROW: Focus previous option +- ENTER or SPACE: Select focused item diff --git a/src/lib/select/README.md b/src/lib/select/README.md index 6d192d19b45..f00c2932cbb 100644 --- a/src/lib/select/README.md +++ b/src/lib/select/README.md @@ -1,3 +1,68 @@ -## Work in progress! +# md-select -The select is still a work in progress, so most features have not been implemented. Not ready for use! \ No newline at end of file +`` is a form control for selecting a value from a set of options, similar to the native +`