news-page.component.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { AuthServiceService } from './../../shared/auth-service.service';
  2. import { ActivatedRoute, Params } from '@angular/router';
  3. import { Component, OnInit } from '@angular/core';
  4. import { InternalPageService } from '../../shared/internal-page.service';
  5. import { NgxSpinnerService } from 'ngx-spinner';
  6. import { CeiboShare } from 'ng2-social-share';
  7. @Component({
  8. selector: 'app-news-page',
  9. templateUrl: './news-page.component.html',
  10. styleUrls: ['./news-page.component.css'],
  11. })
  12. export class NewsPageComponent implements OnInit {
  13. public repoUrl = '';
  14. public imageUrl = '';
  15. constructor(private route: ActivatedRoute,
  16. private authSer:AuthServiceService,
  17. private spinner: NgxSpinnerService,
  18. private internalService: InternalPageService) { }
  19. newsId: number;
  20. newsData = [];
  21. checkLength:boolean = false;
  22. myInnerHeight = window.innerHeight;
  23. image0 = {
  24. photo: ''
  25. }
  26. urlShare: string = '';
  27. ngOnInit() {
  28. this.spinner.show();
  29. this.route.params.subscribe(
  30. (params: Params) => {
  31. this.newsId = params['reportId'];
  32. }
  33. );
  34. this.repoUrl = this.authSer.pathApi + '/get_report/' + this.newsId;
  35. //get news data
  36. this.internalService.getNewsData(this.newsId).subscribe(
  37. (responce) => {
  38. console.log(responce);
  39. this.newsData = responce['report'];
  40. this.image0 = {
  41. photo: this.newsData['photos'].splice( this.newsData['photos'][0].photo , 1)
  42. }
  43. console.log(this.image0);
  44. console.log(this.newsData);
  45. this.spinner.hide();
  46. },
  47. (error) => {
  48. console.log(error);
  49. }
  50. )
  51. }
  52. }