I cant figure out how to achieve the following result.
I have 2 pages. The first one
<ion-header>
<ion-navbar color="primary">
<ion-title>{{evId}} - {{items.list_code}}</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-item *ngFor="let item of items.List_group">
<ion-label>{{item.GroupName}}</ion-label>
<button ion-button clear item-right (click)="goToTemplate(evId,item)">
<ion-icon name="arrow-forward"></ion-icon>
</button>
</ion-item>
<button ion-button class="submit-btn" full type="button" (click)="saveData()" >Save</button>
</ion-content>
and the second
<ion-header>
<ion-navbar color="primary">
<ion-title>{{empl}} - {{items.GroupName}}</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-item *ngFor="let item of items.List_field">
<ion-label>{{item.Field_Name}} - {{item.Field_Type}}</ion-label>
<ion-textarea *ngIf='item.Field_Type==="textarea"' placeholder="Enter a description" ></ion-textarea>
<ion-checkbox *ngIf='item.Field_Type==="chk"' ></ion-checkbox>
<ion-select *ngIf='item.Field_Type==="chklist"' multiple="true" (change)="storeField(item.id,$event)">
<ion-option *ngFor="let option of item.Field_Default_Values" [value]="option.id" >{{option.Value}}</ion-option>
</ion-select>
<ion-select *ngIf='item.Field_Type==="ddl"' >
<ion-option *ngFor="let option of item.Field_Default_Values" [value]="option.id" >{{option.Value}}</ion-option>
</ion-select>
...
</ion-content>
the first one builds dynamically a menu based on the received object: clicking on the button oh each line the app routes to the second page, creating dynamically a list of components depending on their type.
Now I’m struggling trying to save data in the second page, bring them back on the first page, and giving them the structure I need to send the object I need to save to the service.
Each Item on the second page has an id coming from the object received by the service.
{
...
Field_Name:"A/C Type"
Field_Type:"chklist"
id:15
IsMandatory:true
Sequence:1
...
}
At the end on the navigation I need to end up on the first page having an object like this
"list_reportfield": [
{
"Field_id": 0,
"List_Values": ["string"]
}
]
containing a list of all the ids and their values, to be sent to the saving services.
I would like to find an elegant way to achieve this result… something as near as possible to the best practice to do this.
Anybody giving me an hint?
thank U all guys so much