-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(autocomplete): add value support
- Loading branch information
Showing
9 changed files
with
277 additions
and
42 deletions.
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 |
---|---|---|
@@ -1,9 +1,52 @@ | ||
<div class="demo-autocomplete"> | ||
<md-input-container> | ||
<input mdInput placeholder="State" [mdAutocomplete]="auto"> | ||
</md-input-container> | ||
<md-card> | ||
<div>Reactive value: {{ stateCtrl.value }}</div> | ||
<div>Reactive dirty: {{ stateCtrl.dirty }}</div> | ||
|
||
<md-autocomplete #auto="mdAutocomplete"> | ||
<md-option *ngFor="let state of states" [value]="state.code"> {{ state.name }} </md-option> | ||
</md-autocomplete> | ||
<md-input-container> | ||
<input mdInput placeholder="State" [mdAutocomplete]="reactiveAuto" [formControl]="stateCtrl"> | ||
</md-input-container> | ||
|
||
<md-card-actions> | ||
<button md-button (click)="stateCtrl.reset()">RESET</button> | ||
<button md-button (click)="stateCtrl.setValue('California')">SET VALUE</button> | ||
<button md-button (click)="stateCtrl.enabled ? stateCtrl.disable() : stateCtrl.enable()"> | ||
TOGGLE DISABLED | ||
</button> | ||
</md-card-actions> | ||
|
||
</md-card> | ||
|
||
<md-card> | ||
<div>Template-driven value (currentState): {{ currentState }}</div> | ||
<div>Template-driven dirty: {{ modelDir.dirty }}</div> | ||
|
||
<md-input-container> | ||
<input mdInput placeholder="State" [mdAutocomplete]="tdAuto" [(ngModel)]="currentState" #modelDir="ngModel" | ||
(ngModelChange)="this.tdStates = filterStates(currentState)" [disabled]="tdDisabled"> | ||
</md-input-container> | ||
|
||
<md-card-actions> | ||
<button md-button (click)="modelDir.reset()">RESET</button> | ||
<button md-button (click)="currentState='California'">SET VALUE</button> | ||
<button md-button (click)="tdDisabled=!tdDisabled"> | ||
TOGGLE DISABLED | ||
</button> | ||
</md-card-actions> | ||
|
||
</md-card> | ||
</div> | ||
|
||
<md-autocomplete #reactiveAuto="mdAutocomplete"> | ||
<md-option *ngFor="let state of reactiveStates" [value]="state.name"> | ||
<span>{{ state.name }}</span> | ||
<span class="demo-secondary-text"> ({{state.code}}) </span> | ||
</md-option> | ||
</md-autocomplete> | ||
|
||
<md-autocomplete #tdAuto="mdAutocomplete"> | ||
<md-option *ngFor="let state of tdStates" [value]="state.name"> | ||
<span>{{ state.name }}</span> | ||
<span class="demo-secondary-text"> ({{state.code}}) </span> | ||
</md-option> | ||
</md-autocomplete> |
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 |
---|---|---|
@@ -1 +1,18 @@ | ||
.demo-autocomplete {} | ||
.demo-autocomplete { | ||
display: flex; | ||
flex-flow: row wrap; | ||
|
||
md-card { | ||
width: 350px; | ||
margin: 24px; | ||
} | ||
|
||
md-input-container { | ||
margin-top: 16px; | ||
} | ||
} | ||
|
||
.demo-secondary-text { | ||
color: rgba(0, 0, 0, 0.54); | ||
margin-left: 8px; | ||
} |
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
Oops, something went wrong.