Ver Código Fonte

load youtube api in page

golf 3 anos atrás
pai
commit
83c14ce5b7

+ 1 - 7
src/app/news/news.page.ts

10
 })
10
 })
11
 export class NewsPage implements OnInit {
11
 export class NewsPage implements OnInit {
12
 
12
 
13
-  // newsdata: any;
14
-  // data: Observable;
15
   newsdata: any = [];
13
   newsdata: any = [];
16
 
14
 
17
   constructor(private wpgetdataService: WpdataService) { }
15
   constructor(private wpgetdataService: WpdataService) { }
22
 
20
 
23
 
21
 
24
   ionViewWillEnter() {
22
   ionViewWillEnter() {
25
-    // this.wpgetdataService.getAllNews().subscribe((data => {
26
-    //   console.log("get News:");
27
-    //   console.log(data);
28
-    //   this.newsdata = JSON.parse(data.data);
29
     this.wpgetdataService.getAllNews().subscribe((data) => {
23
     this.wpgetdataService.getAllNews().subscribe((data) => {
30
       this.newsdata = data;
24
       this.newsdata = data;
31
-      console.log('load Lineup Data');
25
+      console.log('load News Data');
32
       console.log(this.newsdata);
26
       console.log(this.newsdata);
33
       });
27
       });
34
   }
28
   }

+ 17 - 40
src/app/youtube/youtube.page.html

9
   </ion-toolbar>
9
   </ion-toolbar>
10
 </ion-header>
10
 </ion-header>
11
 <ion-content>
11
 <ion-content>
12
-  <img src="../../../assets/img-static/banner-320x50.jpeg" alt="">
13
   <ion-grid>
12
   <ion-grid>
14
     <ion-row>
13
     <ion-row>
15
       <ion-col>
14
       <ion-col>
17
         <hr>
16
         <hr>
18
       </ion-col>
17
       </ion-col>
19
     </ion-row>
18
     </ion-row>
19
+  </ion-grid>
20
+  <ion-grid>
20
     <ion-row>
21
     <ion-row>
21
-      <ion-col size="5">
22
-        <img src="../../assets/img-static/mqdefault-1.jpg">
23
-      </ion-col>
24
-      <ion-col class="ion-align-self-center">Morning Talk [26-10-2022 l 07:30 - 09:00 น. ]</ion-col>
25
-    </ion-row>
26
-    <ion-row>
27
-      <ion-col size="5">
28
-        <img src="../../assets/img-static/mqdefault-2.jpg">
29
-      </ion-col>
30
-      <ion-col class="ion-align-self-center">Golf Trick [26-10-2022 l 09:00 - 10:00 น.]</ion-col>
31
-    </ion-row>
32
-    <ion-row>
33
-      <ion-col size="5">
34
-        <img src="../../assets/img-static/mqdefault-3.jpg">
35
-      </ion-col>
36
-      <ion-col class="ion-align-self-center">เจาะสนามบอลไทย [ 20-10-2022 l 20:00 - 21:30 น. ]</ion-col>
37
-    </ion-row>
38
-    <ion-row>
39
-      <ion-col size="5">
40
-        <img src="../../assets/img-static/mqdefault-2.jpg">
41
-      </ion-col>
42
-      <ion-col class="ion-align-self-center">Golf Trick [26-10-2022 l 09:00 - 10:00 น.]</ion-col>
43
-    </ion-row>
44
-    <ion-row>
45
-      <ion-col size="5">
46
-        <img src="../../assets/img-static/mqdefault-3.jpg">
47
-      </ion-col>
48
-      <ion-col class="ion-align-self-center">เจาะสนามบอลไทย [ 20-10-2022 l 20:00 - 21:30 น. ]</ion-col>
49
-    </ion-row>
50
-    <ion-row>
51
-      <ion-col size="5">
52
-        <img src="../../assets/img-static/mqdefault-2.jpg">
53
-      </ion-col>
54
-      <ion-col class="ion-align-self-center">Golf Trick [26-10-2022 l 09:00 - 10:00 น.]</ion-col>
55
-    </ion-row>
56
-    <ion-row>
57
-      <ion-col size="5">
58
-        <img src="../../assets/img-static/mqdefault-3.jpg">
22
+      <ion-col class="ion-no-padding">
23
+        <img src="../../../assets/img-static/banner-320x50.jpeg" alt="">
59
       </ion-col>
24
       </ion-col>
60
-      <ion-col class="ion-align-self-center">เจาะสนามบอลไทย [ 20-10-2022 l 20:00 - 21:30 น. ]</ion-col>
61
     </ion-row>
25
     </ion-row>
62
   </ion-grid>
26
   </ion-grid>
63
   <ion-grid>
27
   <ion-grid>
28
+    <div *ngIf="ytdata">
29
+    <ion-card *ngFor="let yt of ytdata['items']" class="list-card-margin">
30
+      <img [src]="yt.snippet.thumbnails.high.url" [style.width]="'100%'" />
31
+      <ion-card-header>
32
+        <a [routerLink]="['' , ]">
33
+          <ion-card-title class="title-txt-1" [innerHTML]="yt.snippet.title"></ion-card-title>
34
+        </a>
35
+      </ion-card-header>
36
+      <ion-card-content text-justify [innerHTML]="yt.snippet.description" class="content-txt-1"></ion-card-content>
37
+    </ion-card>
38
+    </div>
39
+  </ion-grid>
40
+  <ion-grid>
64
     <img src="../../../assets/img-static/banner-320x100.jpeg" alt="">
41
     <img src="../../../assets/img-static/banner-320x100.jpeg" alt="">
65
   </ion-grid>
42
   </ion-grid>
66
 </ion-content>
43
 </ion-content>

+ 26 - 0
src/app/youtube/youtube.page.scss

1
 ion-row {
1
 ion-row {
2
     background-color: #fcfcfc !important;
2
     background-color: #fcfcfc !important;
3
+}
4
+
5
+.list-card-margin {
6
+    margin: 0 0 10px 0;
7
+}
8
+
9
+ion-card-header {
10
+    padding: 5px 10px;
11
+}
12
+
13
+.title-txt-1 {
14
+    font-family: Prompt Reg !important;
15
+    font-size: 1.3em;
16
+    line-height: 1.3em;
17
+    color: darkorange;
18
+}
19
+
20
+ion-card-content {
21
+    padding: 0px 10px 10px;
22
+}
23
+
24
+.content-txt-1 {
25
+    font-family: K2D !important;
26
+    font-size: 1em;
27
+    line-height: 1.3em;
28
+    color: darkslategray;
3
 }
29
 }

+ 11 - 1
src/app/youtube/youtube.page.ts

1
 import { Component, OnInit } from '@angular/core';
1
 import { Component, OnInit } from '@angular/core';
2
+import { WpdataService } from '../services/wpdata.service';
2
 
3
 
3
 @Component({
4
 @Component({
4
   selector: 'app-youtube',
5
   selector: 'app-youtube',
7
 })
8
 })
8
 export class YoutubePage implements OnInit {
9
 export class YoutubePage implements OnInit {
9
 
10
 
10
-  constructor() { }
11
+  ytdata: any;
12
+
13
+  constructor(private wpgetdataService: WpdataService) { }
11
 
14
 
12
   ngOnInit() {
15
   ngOnInit() {
13
   }
16
   }
14
 
17
 
18
+  ionViewWillEnter() {
19
+    this.wpgetdataService.getAllYoutube().subscribe((data) => {
20
+      this.ytdata = data;
21
+      console.log('load Youtube Data');
22
+      console.log(this.ytdata);
23
+    });
24
+  }
15
 }
25
 }