mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 04:53:58 +08:00
Merge pull request #907 from rgv151/path-ion-select-1
fix(select): auto select option w/ default value if none checked
This commit is contained in:
@ -155,7 +155,16 @@ export class Select {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ngAfterContentInit() {
|
ngAfterContentInit() {
|
||||||
let selectedOption = this.options.toArray().find(o => o.checked);
|
var selectedOption = this.options.toArray().find(o => o.checked);
|
||||||
|
|
||||||
|
if(!selectedOption) {
|
||||||
|
this.options.toArray().forEach(o => {
|
||||||
|
o.checked = o.value === this.value + '';
|
||||||
|
if(o.checked) {
|
||||||
|
selectedOption = o;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
if (selectedOption) {
|
if (selectedOption) {
|
||||||
this.value = selectedOption.value;
|
this.value = selectedOption.value;
|
||||||
this.selectedText = selectedOption.text;
|
this.selectedText = selectedOption.text;
|
||||||
|
Reference in New Issue
Block a user