Skip to content

Instantly share code, notes, and snippets.

@chrisegb
Created April 8, 2020 03:51
Show Gist options
  • Save chrisegb/ec93b23f6272b88a11a25bb146632733 to your computer and use it in GitHub Desktop.
Save chrisegb/ec93b23f6272b88a11a25bb146632733 to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import {ViewEncapsulation} from '@angular/core';
import { ApiService } from '../api.service';
@Component({
selector: 'app-post-single',
templateUrl: './post-single.component.html',
styleUrls: ['./post-single.component.css'],
encapsulation: ViewEncapsulation.None,
})
export class PostSingleComponent implements OnInit {
private id: any;
private postData: any;
titulo: string;
private parrafos:any;
private recursos:any;
private numeroDeCosas:number;
todasLasCosasJuntas;
constructor(private activatedroute:ActivatedRoute, private apiService: ApiService) {
this.todasLasCosasJuntas = [];
this.id = this.activatedroute.snapshot.paramMap.get("id");
var json = {
"idPost": this.id
}
this.apiService.getPostById(json).subscribe(
res => {
this.titulo = res["titulo"];
this.parrafos = res["parrafos"];
this.recursos = res["recursosUrls"];
for(var i = 0; i < this.parrafos.length; i++){
this.todasLasCosasJuntas.push(this.parrafos[i]);
}
for(var i = 0; i < this.recursos.length; i++){
this.todasLasCosasJuntas.push(this.recursos[i]);
}
this.todasLasCosasJuntas.sort();
},
err => {
console.log(err);
}
);
}
ngOnInit() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment