Ionic: การเรียกใช้ HTTP แบบ GET

  1. ทดลองเรียกใช้ HTTP
  2. แสดงรายการ (list)

api

1. ทดลองเรียกใช้ HTTP

เรียกใช้ HttpClientModule โดยการ
แก้ไขไฟล์ src/app/app.module.ts

Now we are ready to make HTTP calls to anywhere we want!

แก้ไขไฟล์ src/pages/home/home.ts
ให้เรียกไปที่ https://swapi.co/api/films

ดูที่ Debug ด้วยการกด F12 ดูก็จะเห็นข้อมูลที่วิ่งมาละ

2. แสดงรายการ (list)

แก้ไขไฟล์ src/pages/home/home.ts

แก้ไขไฟล์ src/pages/home/home.html

list

สร้าง page ใหม่ชื่อ detail

[code]
$ ionic g page detail
[/code]

แก้ไขไฟล์ src/pages/detail/detail.ts

แก้ไขไฟล์ src/pages/detail/detail.html

list2

Link