Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. A lista esta funcionando perfeitamente, mas não consigo entender o porque do erro no console
  2. Na imagem aparecem a tabela, o console e o array agrupado por medico
  3. Sou novato e autodidata e nem sei se usei o método correto para fazer este tipo de tabela ...
  4.  
  5. <table class="table table-hover">
  6. <ng-container *ngFor="let medico of consultas[0]">
  7.  
  8. <thead>
  9. <tr class="bg-primary text-light">
  10. <th>Medico</th>
  11. <th>Paciente</th>
  12. <th>Data Agendada</th>
  13. </tr>
  14. </thead>
  15.  
  16. <p> <strong> {{medico.nomeMedico}} </strong> </p>
  17.  
  18. <tbody>
  19. <tr *ngFor="let consulta of medico.consultas">
  20. <td></td>
  21. <td>{{consulta.nome}}</td>
  22. <td>{{consulta.dataConsultaFrm}} - {{consulta.horaConsulta}}</td>
  23. </tr>
  24. </tbody>
  25.  
  26. </ng-container>
  27.  
  28. import { Component, OnInit } from '@angular/core';
  29. var _ = require('lodash');
  30.  
  31. import { Consulta } from 'src/app/models/consulta.model';
  32. import { ConsultaService } from 'src/app/services/consulta.service';
  33.  
  34. @Component({
  35. selector: 'app-consultas-listagem',
  36. templateUrl: './consultas-listagem.component.html',
  37. styleUrls: ['./consultas-listagem.component.css']
  38. })
  39. export class ConsultasListagemComponent implements OnInit {
  40.  
  41. consultas: Consulta[];
  42.  
  43. constructor(
  44. private consultaService: ConsultaService
  45. ) { }
  46.  
  47. ngOnInit() {
  48. this.consultaService.getConsultas().subscribe(
  49. consultas => {
  50. var result = _(consultas)
  51. .groupBy(x => x.nomeMedico)
  52. .map((value, key) => ({nomeMedico: key, consultas: value}))
  53. .value();
  54. this.consultas = Array.of(result);
  55.  
  56. console.log(this.consultas);
  57. }
  58. );
  59. }
  60. }
  61.  
  62. consultas: Consulta[] = [];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement