html IF_06_07_home.page.html
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html IF_06_07_home.page.html相关的知识,希望对你有一定的参考价值。
import { Component } from '@angular/core';
import { LoadingController } from '@ionic/angular';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
posts: any[] = [];
constructor(private httpClient: HttpClient, private loadingController: LoadingController) {
this.getPosts();
}
async getPosts() {
let loading = await this.loadingController.create({
message: "Loading Posts..."
});
await loading.present();
// Making the GET request
this.httpClient.get("https://jsonplaceholder.typicode.com/posts").subscribe((response) => {
// Request succeeded
console.log(response)
this.posts = response as any[];
loading.dismiss();
}, (error) => {
// Request failed with an error
console.log(error);
loading.dismiss();
})
}
}
以上是关于html IF_06_07_home.page.html的主要内容,如果未能解决你的问题,请参考以下文章
html IF_03_07_Round_Button
html IF_03_06_Fill_Button
typescript IF_04_07_Checkbox_Binding_HTML
07_Python的控制判断循环语句1(if判断for循环)_Python编程之路
python06_流程控制
node.js 相当于 python 的 if __name__ == '__main__' [重复]