How can I output the following data (see Picture below, blue arrow)
as a JSON array like:
{
“name”: “John”,
“title”:30,
“phone”: “+39493849”
}
I have tried JSON.stringify
here is my .ts:
public createQRcode(item: Vkarten){
this.visitenkarteService.getItems().then(items => {
let result: any;
result = [
item.title,
item.name,
item.telefon
];
this.createCode = JSON.stringify(result);
});
this.mylist.closeSlidingItems();
this.loadItems();
}
i tried to take item instead of result, but i get then to much information that i dont want.
here is my .html:
<ion-list #mylist>
<ion-list-header>
<ion-label>Meine Visitenkarten (Um zu Löschen,Upzudaten oder QR-Code zu generieren nach links Sliden!)</ion-label>
</ion-list-header>
<ion-item-sliding *ngFor="let item of items">
<ion-item color="light">
<ion-label text-wrap>
<h3>{{ item.title }}</h3>
<p>{{ item.name }}</p>
<ion-text color="secondary">
<p>{{ item.telefon }}</p>
</ion-text>
<p>{{ item.modified | date:'short'}}</p>
</ion-label>
</ion-item>
<ion-item-options side="end">
<ion-item-option color="secondary" (click)="updateItem(item)">Update</ion-item-option>
<ion-item-option color="danger" (click)="deleteItem(item)">Delete</ion-item-option>
<ion-item-option color="primary" (click)="createQRcode(item)">Generate QR</ion-item-option>
</ion-item-options>
</ion-item-sliding>
</ion-list>
here is Vkarten:
export interface Vkarten {
id: number;
name: number;
title: string;
telefon: number;
modified: number;
}
if you need something else, tell me
i hope this is not a stupid question, it would help me a lot if you could give me a tutorial or a topic how i should proceed.