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>