From 70de6485388163d236933aa414dcdf2a5d9aff68 Mon Sep 17 00:00:00 2001 From: Bruce Doan Date: Sun, 10 Jan 2016 00:07:14 +0700 Subject: [PATCH] Auto select Option with default value if none is checked --- ionic/components/select/select.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ionic/components/select/select.ts b/ionic/components/select/select.ts index 6dbc66bd5c..55215ca341 100644 --- a/ionic/components/select/select.ts +++ b/ionic/components/select/select.ts @@ -155,7 +155,16 @@ export class Select { * @private */ 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) { this.value = selectedOption.value; this.selectedText = selectedOption.text;