import { AuthServiceService } from './../../shared/auth-service.service'; import { ActivatedRoute, Params } from '@angular/router'; import { Component, OnInit } from '@angular/core'; import { InternalPageService } from '../../shared/internal-page.service'; import { NgxSpinnerService } from 'ngx-spinner'; import { CeiboShare } from 'ng2-social-share'; @Component({ selector: 'app-news-page', templateUrl: './news-page.component.html', styleUrls: ['./news-page.component.css'], }) export class NewsPageComponent implements OnInit { public repoUrl = ''; public imageUrl = ''; constructor(private route: ActivatedRoute, private authSer:AuthServiceService, private spinner: NgxSpinnerService, private internalService: InternalPageService) { } newsId: number; newsData = []; checkLength:boolean = false; myInnerHeight = window.innerHeight; image0 = { photo: '' } urlShare: string = ''; ngOnInit() { this.spinner.show(); this.route.params.subscribe( (params: Params) => { this.newsId = params['reportId']; } ); this.repoUrl = this.authSer.pathApi + '/get_report/' + this.newsId; //get news data this.internalService.getNewsData(this.newsId).subscribe( (responce) => { console.log(responce); this.newsData = responce['report']; this.image0 = { photo: this.newsData['photos'].splice( this.newsData['photos'][0].photo , 1) } console.log(this.image0); console.log(this.newsData); this.spinner.hide(); }, (error) => { console.log(error); } ) } }