Guest User

Untitled

a guest
Feb 22nd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. import { Injectable } from '@angular/core';
  2. import { HttpClient, HttpHeaders,HttpParams } from "@angular/common/http";
  3. import { video, videosgeneral } from '../models/videos';
  4. import { Observable } from 'rxjs/Rx';
  5.  
  6.  
  7. @Injectable()
  8. export class VideosService {
  9. videos: Array<video>;
  10. videoid: Array<video>;
  11. listavideos:Array<video>;
  12. public VideosApi = 'https://rinnolab.vms.grupoz.cl/api/v1/video';
  13. public token = '59026a6cd7dd4cc7a5517090659b9bf6';
  14. public paginas:number;
  15.  
  16. constructor(public http: HttpClient) {
  17.  
  18.  
  19. }
  20.  
  21. getVideos(): Observable<any>{
  22. const headers = { 'Authorization': 'bearer 59026a6cd7dd4cc7a5517090659b9bf6' };
  23. const params = { 'page': '1' };
  24. return this.http.get(this.VideosApi, { headers:headers, params });
  25.  
  26. }
  27.  
  28.  
  29.  
  30. }
  31.  
  32. import { Component, OnInit } from '@angular/core';
  33. import { HttpClient, HttpParams, HttpEventType } from "@angular/common/http";
  34. import { video } from '../models/videos';
  35. import { VideosService } from '../servicios/videos.service';
  36. import { Observable } from 'rxjs/Rx';
  37.  
  38.  
  39. @Component({
  40. selector: 'app-home',
  41. templateUrl: './home.component.html',
  42. styleUrls: ['./home.component.scss'],
  43. providers:[VideosService]
  44. })
  45. export class HomeComponent implements OnInit {
  46. public videosService:Array<any>;
  47. public listavideos:any;
  48. public videos: video[];
  49.  
  50. constructor(private http : HttpClient, videoService: VideosService) {
  51. this.listavideos.getVideos().subscribe(
  52. data => {
  53.  
  54. if(data.code != 200){
  55. console.log(data);
  56. }else{
  57. this.listavideos = data['videos']['data'];
  58. console.log(data['videos']['data']);
  59. }
  60.  
  61. },
  62. error => {
  63. console.log(<any>error);
  64. }
  65. );
  66.  
  67.  
  68. }
  69.  
  70.  
  71. ngOnInit() {
  72.  
  73.  
  74.  
  75. }
  76.  
  77.  
  78. }
  79.  
  80. <div class="row">
  81. <div class="col s12 m4 l3" *ngFor="let video of listavideos" id="{{video.vid}}">
  82. <div class="video">
  83. <div class="thumb">
  84. <div class="hover-efect"></div>
  85. <small class="time">{{video.duration}}</small>
  86. <a routerLink="/video"><img [src]="video.thumb" alt=""></a>
  87. </div>
  88.  
  89. <div class="video-info">
  90. <a routerLink="/" class="title truncate">{{video.name}}</a>
  91. <a class="channel-name" routerLink="/">Categoria: {{video.category}}<span>
  92. <i style="display:none;" class="material-icons">person</i></span></a>
  93. <span class="views">
  94. <i class="material-icons">visibility</i>{{video.total_views}} visitas
  95. </span>
  96. <span class="date">
  97. <i class="material-icons">access_time</i>{{video.begins}}
  98. </span>
  99. </div>
  100.  
  101. </div>
  102. </div>
  103. </div>
  104.  
  105. Error: [object Object]
  106. Stack trace:
  107. resolvePromise@webpack-internal:///../../../../zone.js/dist/zone.js:821:31
  108. resolvePromise@webpack-internal:///../../../../zone.js/dist/zone.js:785:17
  109. scheduleResolveOrReject/<@webpack-internal:///../../../../zone.js/dist/zone.js:870:17
  110. ZoneDelegate.prototype.invokeTask@webpack-internal:///../../../../zone.js/dist/zone.js:421:17
  111. onInvokeTask@webpack-internal:///../../../core/esm5/core.js:4941:24
  112. ZoneDelegate.prototype.invokeTask@webpack-internal:///../../../../zone.js/dist/zone.js:420:17
  113. Zone.prototype.runTask@webpack-internal:///../../../../zone.js/dist/zone.js:188:28
  114. drainMicroTaskQueue@webpack-internal:///../../../../zone.js/dist/zone.js:594:25
Add Comment
Please, Sign In to add comment