Guest User

Untitled

a guest
Dec 1st, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. import { area } from "./area";
  2. import { actividad_persona } from "./actividad_persona";
  3. import { DocumentReference } from "angularfire2/firestore";
  4.  
  5. export interface persona {
  6. id?: string
  7. nombre: string
  8. apellidos: string
  9. area: area
  10. areaRef?: DocumentReference;
  11. UserName: string
  12. password: string
  13. actividad_persona: actividad_persona[]
  14. }
  15.  
  16. import { Injectable } from '@angular/core';
  17. import { persona } from '../modelos/persona';
  18. import { AngularFirestoreCollection, AngularFirestore } from 'angularfire2/firestore';
  19. import { map } from 'rxjs/operators';
  20. import { Observable } from 'rxjs';
  21. import { actividades } from '../modelos/actividades';
  22. import { actividad_persona } from '../modelos/actividad_persona';
  23. import { area } from '../modelos/area';
  24.  
  25. @Injectable({
  26. providedIn: 'root'
  27. })
  28. export class PersonaService {
  29. private personaCollection: AngularFirestoreCollection<persona>
  30. persona: persona
  31. constructor(private afs: AngularFirestore) {
  32. this.personaCollection = this.afs.collection<persona>('persona')
  33. }
  34. getPersonaFindId(idPersona: string): Observable<persona> {
  35. return this.afs.collection<persona>("persona").doc(idPersona).snapshotChanges().pipe(map(actions => {
  36. const id = actions.payload.id;
  37. const data = actions.payload.data() as persona;
  38. data.areaRef.onSnapshot(p=>{
  39.  
  40. })
  41.  
  42. console.log(data.areaRef.id)
  43. return { id, ...data };
  44. }))
Add Comment
Please, Sign In to add comment