I am having some problem on ionic. I am not able to display data on screen via http in ionic.
i only showing data on google console.
this is the code of the file.
home.page.html (home page code)*
users{{users}}<ion-item *ngIf=“users”>
username{{users}}
home.page.ts (ts file code)*
import { Component } from ‘@angular/core’;
import { NavController } from ‘@ionic/angular’;
import { HttpClientModule } from ‘@angular/common/http’;
import { HttpClient } from ‘@angular/common/http’;
@Component({
selector: ‘app-home’,
templateUrl: ‘home.page.html’,
styleUrls: [‘home.page.scss’],
})
export class HomePage {
users: any=;
constructor(
public navctrl: NavController,
public httpclient: HttpClient,
public httpclientmodule: HttpClientModule
) {
this.getdata();
}
getdata() {
this.httpclient
.get(‘https://jsonplaceholder.typicode.com/users’)
.subscribe(
(data) => {
console.log(data);
this.users = [data];
},
(error) => {
console.log(error);
}
);
}
}
Output screen