hello
how are you ?
i’m new in ionic and javascript so i have json file from drupal8 and this some of content in the json file
[
{
"title": "اختناق مروري",
"field_case_details": "<p>حالة اختناق مروري في منى</p>\n",
"field_hajj_program_number": "<a href=\"/taxonomy/term/2\" hreflang=\"en\">حملة عون</a>",
"field_image": "http://54.161.232.107/sites/default/files/styles/thumbnail/public/2018-08/%D9%83%D9%8A%D9%81_%D8%AA%D8%A4%D8%AF%D9%8A_%D9%85%D9%86%D8%A7%D8%B3%D9%83_%D8%A7%D9%84%D8%AD%D8%AC_4.jpg?itok=v92JBHqG",
"field_location": "منى-مكة",
"field_name": "سلمى",
"field_phone_number": "<a href=\"tel:058421658\">058421658</a>"
},
and i use this code in ts file for get method and it work and bring the content to me
export class LostPage {
public items:any;
constructor(public navCtrl: NavController, public http: HttpClient) {
this.getData();
}
getData(){
let url='MyJsonURl';
let data: Observable<any> = this.http.get(url);
data.subscribe(result => {
this.items = result;
});
}
}
and now i want to post content form ionic to drupal i make this html code
<form (ngSubmit)="PostData()">
<ion-item>
<ion-label>title</ion-label>
<ion-input type="text" [(ngModel)]="title" name="title"></ion-input>
</ion-item>
<ion-item>
<ion-label>field_case_details</ion-label>
<ion-input type="text" [(ngModel)]="field_case_details" name="case_datails"></ion-input>
</ion-item>
<ion-item>
<ion-label>field_location</ion-label>
<ion-input type="text" [(ngModel)]="field_location" name="loaction"></ion-input>
</ion-item>
<button ion-button type="submit" block>add content</button>
</form>
and this code in ts file
export class AddtrafficPage {
public items:any;
title: any;
field_case_details: any;
field_location: any;
mydata: any;
constructor(public navCtrl: NavController, public http: HttpClient , public restProvider: ResolvedReflectiveProvider) {
this.PostData();
}
PostData(){
let postParams = {
"title": this.title,
"case_datails": this.field_case_details,
"loaction": this.field_location
}
this.http.post("MyjsonURL",JSON.stringify(postParams))
.subscribe(data => {
this.PostData =data.json()
let response = this.mydata.code;
alert(response);
}, error => {
// Error getting the data
console.log(error);
});
}
}
but when i click on submit button no thing happen can you help me to post what i wrote in ionic to drupal and for your knowledge i gave permission for any one to add content in drupal
thanks