2
Making an array of selects using multi-select, but select them is not communicating, when I select one appears in the json, but when I go to select another subscribes those I selected. I’m using Angular 4.
Follow the link below to test the function.
Staackblitz: https://stackblitz.com/edit/angular-tjgycw?file=src/app/app.component.html
JSON
Component
colecaoGrupoPermissoes: ColecaoGrupoPermissao[];
this.perfilAcessoService.findAllPermissoes()
.subscribe(colecaoGrupoPermissoes => {
console.log(colecaoGrupoPermissoes)
this.colecaoGrupoPermissoes = colecaoGrupoPermissoes;
})
this.perfilAcessoForm = this.builder.group({
id: [],
nome: ['', [Validators.required, Validators.maxLength(120)]],
tipoPerfil: ['', [Validators.required]],
unidade: this.builder.group({
id: ['', [Validators.required]]
}),
descricao: ['', [Validators.required, Validators.maxLength(80)]],
permissoes: ([{}]),
}, {});
Html
<div id="collapse{{i}}" class="accordion-body collapse" aria-expanded="false" style="">
<div class="panel-body">
<!-- BUTTON ADD FORMAÇÃO -->
<div class="row">
<div *ngFor="let grupoPermissao of colecaoGrupoPermissao.grupoPermissoes">
<div class="col-md-6">
<p>{{grupoPermissao.nome | translate}}</p>
</div>
<div class="col-md-6">
<input-container fieldErrorCode="{{extractErrorCode('permissao')}}" fieldName="permissao">
<select class="form-control" formControlName="permissoes" [compareWith]="compareFn" multiple>
<option *ngFor="let permissao of grupoPermissao.permissoes" [ngValue]="permissao">{{permissao.nome}}</option>
</select>
</input-container>
</div>
</div>
</div>
</div>
</div>
Please post the code instead of images.
– Eduardo Vargas
https://pt.meta.stackoverflow.com/questions/5483/manual-de-como-n%C3%83o-fazer-perguntas/5485#5485
– Eduardo Vargas
tries to create a stackblitz showing its error, I could not replicate here. Make a test exchange the [ngValue] for so value.
– Eduardo Vargas
changed with the stackblitz
– Lucas
Just hold on to Ctrl man
– Eduardo Vargas
Here you are working
– Eduardo Vargas
Select different fields, in the same select they group, but need them to work in more than one select.
– Lucas
in which case you need a control for each select
– Eduardo Vargas
It’s time to save you concatenate
– Eduardo Vargas
I’m sorry, but I don’t understand what you intend to do, what would it be? Because for me it’s working normally ...
– Herbert Junior
I’m having trouble right now between the accordion I’m using. Every time you open accordion the permission array-0:[ ] overwrite the previous accordion that was closed.
– Lucas