feat(select): add placeholder as an input for select

closes #6862
This commit is contained in:
Brandy Carney
2016-06-14 20:24:35 -04:00
parent ea450d41d3
commit 461ba11de9
5 changed files with 24 additions and 2 deletions

View File

@ -10,12 +10,17 @@ $select-ios-padding-bottom: $item-ios-padding-bottom !default;
$select-ios-padding-left: $item-ios-padding-left !default; $select-ios-padding-left: $item-ios-padding-left !default;
$select-ios-icon-color: #999 !default; $select-ios-icon-color: #999 !default;
$select-ios-placeholder-color: $select-ios-icon-color !default;
ion-select { ion-select {
padding: $select-ios-padding-top $select-ios-padding-right $select-ios-padding-bottom $select-ios-padding-left; padding: $select-ios-padding-top $select-ios-padding-right $select-ios-padding-bottom $select-ios-padding-left;
} }
.select-placeholder {
color: $select-ios-placeholder-color;
}
.select-icon { .select-icon {
position: relative; position: relative;

View File

@ -10,12 +10,17 @@ $select-md-padding-bottom: $item-md-padding-bottom !default;
$select-md-padding-left: $item-md-padding-left !default; $select-md-padding-left: $item-md-padding-left !default;
$select-md-icon-color: #999 !default; $select-md-icon-color: #999 !default;
$select-md-placeholder-color: $select-md-icon-color !default;
ion-select { ion-select {
padding: $select-md-padding-top $select-md-padding-right $select-md-padding-bottom $select-md-padding-left; padding: $select-md-padding-top $select-md-padding-right $select-md-padding-bottom $select-md-padding-left;
} }
.select-placeholder {
color: $select-md-placeholder-color;
}
.item-select ion-label { .item-select ion-label {
margin-left: 0; margin-left: 0;
} }

View File

@ -116,7 +116,8 @@ const SELECT_VALUE_ACCESSOR = new Provider(
@Component({ @Component({
selector: 'ion-select', selector: 'ion-select',
template: template:
'<div class="select-text">{{_text}}</div>' + '<div *ngIf="!_text" class="select-placeholder select-text">{{placeholder}}</div>' +
'<div *ngIf="_text" class="select-text">{{_text}}</div>' +
'<div class="select-icon">' + '<div class="select-icon">' +
'<div class="select-icon-inner"></div>' + '<div class="select-icon-inner"></div>' +
'</div>' + '</div>' +
@ -159,6 +160,11 @@ export class Select {
*/ */
@Input() okText: string = 'OK'; @Input() okText: string = 'OK';
/**
* @input {string} The text to display when the select is empty.
*/
@Input() placeholder: string;
/** /**
* @input {any} Any addition options that the alert interface can take. * @input {any} Any addition options that the alert interface can take.
* See the [Alert API docs](../../alert/Alert) for the create options. * See the [Alert API docs](../../alert/Alert) for the create options.

View File

@ -17,7 +17,9 @@ $select-wp-border-color: $input-wp-border-color !default;
$select-wp-icon-width: 18px !default; $select-wp-icon-width: 18px !default;
$select-wp-icon-arrow-width: 2px !default; $select-wp-icon-arrow-width: 2px !default;
$select-wp-icon-color: $select-wp-border-color !default; $select-wp-icon-color: $select-wp-border-color !default;
$select-wp-placeholder-color: $select-wp-icon-color !default;
ion-select { ion-select {
@ -32,6 +34,10 @@ ion-select {
line-height: 3rem; line-height: 3rem;
} }
.select-placeholder {
color: $select-wp-placeholder-color;
}
.item-select ion-label { .item-select ion-label {
margin-left: 0; margin-left: 0;
} }

View File

@ -49,7 +49,7 @@
<ion-item> <ion-item>
<ion-label>Music</ion-label> <ion-label>Music</ion-label>
<ion-select [(ngModel)]="music" [alertOptions]="musicAlertOpts"> <ion-select [(ngModel)]="music" [alertOptions]="musicAlertOpts" placeholder="Select Music">
<ion-option>Alice in Chains</ion-option> <ion-option>Alice in Chains</ion-option>
<ion-option>Green Day</ion-option> <ion-option>Green Day</ion-option>
<ion-option>Nirvana</ion-option> <ion-option>Nirvana</ion-option>