0
I need to create a function that deletes records according to the checkbox(s) selected(s). I was able to select these Ids for each checkbox and include them in the array "Selected" through function alternating(), but now I need to create a function to exclude these ids stored in "Selected" which correspond to main array records "people".
html
<tr *ngFor="let pessoa of pessoasArray; let i = index">
<th><input type="checkbox" name="" (click)="alternaSelecao(pessoa)"/></th>
<!-- <th>{{pessoa.$key}}</th> -->
<td>{{ i+1 }}</td>
<td>{{pessoa.nome}}</td>
<td>{{pessoa.email}}</td>
<td>{{pessoa.tipo}}</td>
<td>{{pessoa.datanasc}}</td>
<td>
class
export class PessoaComponent implements OnInit {
constructor(public bd: Bd) { }
selected = [];
public pessoasArray
ngOnInit() {
this.bd.getPessoas().subscribe(
list => {
this.pessoasArray = list.map(item => {
return {
$key: item.key,
...item.payload.val()
};
});
});
}
alternaSelecao(pessoa) {
let idx = this.selected.indexOf(pessoa);
if(idx > -1){
this.selected.splice(idx,1);
}
else {
this.selected.push(pessoa);
}
}
service comic:
export class Bd {
constructor(private firebase: AngularFireDatabase) { }
public pessoasList: AngularFireList<any>;
public getPessoas() {
this.pessoasList = this.firebase.list('pessoa');
return this.pessoasList.snapshotChanges();
}
You could pass me an array containing the list?
– Pedro Henrique Cndido Ferreira