hi,
I’m trying to figure out with two things at the same time in ionic2 application for one desired result.
I want to add names for check boxes menu from list public names: any = [];
to get same menu, if I just list names into the page.html:
<ion-item class="ion-selector">
<ion-label>Set 1</ion-label>
<ion-select [(ngModel)]="SelectedValues1" multiple="true">
<ion-option>Name1</ion-option>
<ion-option>Name2</ion-option>
<ion-option>Name3</ion-option>
</ion-select>
</ion-item>
If I have a list in my page.ts:
this.names = [
'Name1',
'Name2',
'Name3',
];
This way *ngFor="let name of names"
seems incorrect, because I have list of check boxes instead of menu with check boxes:
<ion-item class="ion-selector" *ngFor="let name of names">
<ion-label>Set 1</ion-label>
<ion-select [(ngModel)]="SelectedValues1" multiple="true">
<ion-option> {{name}} </ion-option>
</ion-select>
</ion-item>
Reason why I’m want to do that, I’m trying to figure out, what is a correct way dynamically add new menu of check boxes on empty form, in the amount that the user would like, with button “add” for example, to avoid two listings in form like this:
Set 1 [(ngModel)]="SelectedValues1"
:
<ion-item class="ion-selector">
<ion-label>Set 1</ion-label>
<ion-select [(ngModel)]="SelectedValues1" multiple="true">
<ion-option>Name1</ion-option>
<ion-option>Name2</ion-option>
<ion-option>Name3</ion-option>
</ion-select>
</ion-item>
same as if I add Set 2 with [(ngModel)]="SelectedValues2"
:
<ion-item class="ion-selector">
<ion-label>Set 2</ion-label>
<ion-select [(ngModel)]="SelectedValues2" multiple="true">
<ion-option>Name1</ion-option>
<ion-option>Name2</ion-option>
<ion-option>Name3</ion-option>
</ion-select>
</ion-item>
And then also must be passed to function:
<button ion-button (click)="Go(SelectedValues1, SelectedValues2);">Ok</button>
Advice would be helpful