0
タイトルにはすべてが表示されます。私はIonicで比較的シンプルなハイブリッドアプリケーションをやる必要があり、ボタンを押したときにいくつかのイオン選択で選択された値を取得したい。ここでは、コード行く:リスト内の選択から値を選択する - イオン
page.html
<ion-content padding>
<div id="sectionTitle"> </div>
<ion-list>
<ion-item *ngFor="let question of questions" (click)="itemSelected(question)">
<ion-label>{{question.texto}} </ion-label>
<ion-select>
<option ng-selected="selected">{{answers[0].texto}}</option>
<ion-option text-wrap required *ngFor="let answer of answers; let i = index" onchange="itemSelected(answer)">
<p> {{answer.text}} </p>
</ion-option>
</ion-select>
</ion-item>
</ion-list>
<div class="sendButton">
<button ion-button full type="submit" (click)="toComparisonPage()">
Send
<!-- Here is where data must be retrieved -->
</button>
</div>
</ion-content>
page.ts事前に
itemSelected(answer){
console.log("Selected item: ");
}
おかげで!!
、私はngModelを指定しなかったが、これらの選択がdynamicaly作成されると、私は彼らがそのngModelを、共有して考えますそれらのうちの1つが変更されると、それらのすべてが自動的に変更されます。S – camnuel
あなたはオブジェクト/配列を持ち、* ngForから適切なインデックスに値を格納できます。 例: '* ngFor ="質問の質問をさせてください。 "i = index"としましょう。 'ng-selected =" selected [i] "' –