Guest User

Untitled

a guest
Jan 20th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. [
  2. {
  3. "id": 64,
  4. "name": "Utopia",
  5. "language": "English",
  6. "genres": [
  7. "Drama",
  8. "Science-Fiction",
  9. "Thriller"
  10. ],
  11. "status": "Ended",
  12. "image": {
  13. "medium": "http://static.tvmaze.com/uploads/images/medium_portrait/0/474.jpg",
  14. "original": "http://static.tvmaze.com/uploads/images/original_untouched/0/474.jpg"
  15. }
  16. },
  17. {
  18. "id": 65,
  19. "name": "Bones",
  20. "language": "English",
  21. "genres": [
  22. "Drama",
  23. "Crime",
  24. "Medical"
  25. ],
  26. "status": "Ended",
  27. "image": {
  28. "medium": "http://static.tvmaze.com/uploads/images/medium_portrait/80/201202.jpg",
  29. "original": "http://static.tvmaze.com/uploads/images/original_untouched/80/201202.jpg"
  30. }
  31. }
  32. ]
  33.  
  34. @Component({
  35. selector: 'app-shows',
  36. templateUrl: './shows.component.html',
  37. styleUrls: ['./shows.component.css']
  38. })
  39. export class ShowsComponent implements OnInit {
  40.  
  41. public gridOptions: GridOptions;
  42. public tvShowsColumnDefs = new ShowColumn;
  43. public showMetaData: any;
  44.  
  45. constructor(private _contentService: ContentService, private _router: Router,
  46. private _route: ActivatedRoute) {
  47.  
  48. // GridOptions Initialized
  49. this.gridOptions = <GridOptions>{};
  50. this.gridOptions.columnDefs = this.tvShowsColumnDefs.columnDefs;
  51. }
  52.  
  53. ngOnInit() {
  54. // Prepare Grid Row Data
  55. this.prepareRowData();
  56. }
  57.  
  58. prepareRowData() {
  59. // API Call for getting TV-Shows
  60. this._contentService.getAllShows()
  61. .subscribe(response => {
  62. const shows = response;
  63. console.log('TVShows-API Response ', shows);
  64.  
  65. // Setting Grid RowData using api response
  66. this.gridOptions.api.setRowData(shows);
  67.  
  68. });
  69. }
  70.  
  71. export class ShowColumn {
  72.  
  73. public columnDefs = [
  74. { field: 'id', headerName: '', width: 50 },
  75. { field: 'image', headerName: '', width: 50, cellRendererFramework: null},
  76. { field: 'name', headerName: '', width: 250},
  77. { field: 'language', headerName: 'Language', width: 100},
  78. { field: 'genres', headerName: 'Genres', width: 250},
  79. { field: 'status', headerName: 'Status', width: 145 }
  80. ];
  81. constructor() { }
  82. }
Add Comment
Please, Sign In to add comment