Angular - Subgroup according to group id

0

I need the subgroup to be generated according to the group selected. I was able to go up to submit the id that was selected in the html, not able to pass this value to the getid.

I'm using Angular 6 + primeNg

component group

  grupo: Group[];
  @Output() idSelecionado = new EventEmitter();
   ngOnInit() { this.getListGroup();}

// Busca todos os grupos já cadastrados
  getListGroup() {
    this.service.getAllGroup()
      .subscribe(data => {
        this.grupo = data;
        console.log(data);
      });
  }
  // retorna o id que foi selecionado na lista
  onRowSelect(event) {
   this.idSelecionado.emit(event.data.id);
  }

Subgroup Component

  subgrupo: Subgroup[];
    @Input() idGrupo: any;

   getIdGroup() {
        this.service.getIdSubgroup(this.idGrupo)
          .subscribe(data => {
            this.subgrupo = data;
          });
      }

parent html component

  idGroup: any;
  @Output() idTest = new EventEmitter();

  aoSelecionar(id) {
   this.idGroup = id;
    console.log('O componente classificationn escutou o id: ${id}' );
  }

html that is featuring others

  <div class="ui-g-6">
        <app-classification-group-form></app-classification-group-form>
        <app-classification-group-list (idSelecionado)='aoSelecionar($event)'></app-classification-group-list>
    </div>

    <div class="ui-g-6">

        <app-classification-subgroup-form></app-classification-subgroup-form>
        <app-classification-subgroup-list ></app-classification-subgroup-list>
       Escutando {{idGroup}}
    </div>

    
asked by anonymous 06.08.2018 / 20:04

1 answer

0

<app-classification-subgroup-list [idGrupo]="idGroup" ></app-classification-subgroup-list> Try to do this ... to pass the id to the subgroup and use ngOnChanges to call the method.

    
06.08.2018 / 20:46