<h2 mat-dialog-title [class]="data.color">{{ data.title }}</h2>
<ng-container>
<ng-container>
<mat-dialog-content>
<p [innerHTML]="data.subtitle"></p>
</mat-dialog-content>
</ng-container>
<mat-selection-list #options>
<mat-list-option *ngFor="let cert of certidoes; let index = index; let last = last" [value]="cert">
<tr>
<td>
<strong>{{ cert.numero_cpha }}</strong>
</td>
<td>
<form [formGroup]="form">
<mat-form-field class="example-form-field" appearance="standard">
<mat-label>nº OP</mat-label>
<input matInput #opField formControlName="op">
<!--mat-error *ngIf="form.get('op')?.invalid">{{ getErrorsMsgField() }}</mat-error-->
</mat-form-field>
</form>
</td>
</tr>
<mat-divider *ngIf="!last"></mat-divider>
</mat-list-option>
</mat-selection-list>
<mat-divider></mat-divider>
<p style="padding-top: 15px;">
Opções selecionadas: {{options.selectedOptions.selected.length}}
</p>
<mat-dialog-actions align="end">
<button mat-button [mat-dialog-close]="true" color="primary"
(click)="onClick(options.selectedOptions.selected)">Enviar</button>
</mat-dialog-actions>
</ng-container>```
#Send MatListOption with inputs
39 messages · Page 1 of 1 (latest)
onClick(cert: MatListOption[]) {
// this.dialogRef.close(cert.map(o => o.value));
console.log(cert.map(o => o.value));
}```
What your API expects to receive?
I need to receive what was selected, what I already get with this code in onClick, and what was inserted in the input
For example... [1, 123456] For input id 1 the value is 123456
understand?
Yes, but exactly how the payload has to be shaped?
I need to receive what information was selected and what information was entered for it.
Again: what type of payload does your API endpoint expect?
I did not understand your question
Where are you sending those data?
It's a dialog. After getting this data, I send it to my service to send it to the database
Please, post the code of the service's method you use for sending these data.
Want to see the receipt code?
The code is not quite ready yet. I need to receive the information from the inputs to correct the sending to the service
The method issuing the http request.
I need to know what your backend expects to receive.
My backend expects to receive the ID of the selected Certificate, the OP that will be inserted in the input, referring to this certificate and the date it was sent
* @returns Observable<Array<ICertidao>>
*/
pagamentoAll() {
//console.log(autoriza);
return this.http.get<Array<ICertidao>>(`${AppService.apiUrl}/certidao/paymentAll`);
}```` the service is this. I have to pass an array of ids, with the value of the corresponding inputs
this is my idea
Please, post the code or the spec of that API endpoint because I cannot understand your requirement.
my submission would be like this... ```ts
.
.
.
console.log(ids);
this.pagamentosService.pagamentoAll(cphas).subscribe({
next: (paga) => {
this.paga = paga;
this.loading = false;
}
});
this.certService.proceedAll(ids, user_id, departamento, observacao).subscribe({
next: () => this.loadMyCerts()
});
.
.
.````
I'll try to be more exact...
this is my dialog
👇🏿
When clicking on the checkbox to select what I want to send, I need to fill in the input referring to what I selected.
I need that when I click send, the id of what I selected and the input information are sent in an array
You should send an array of objects.
Every object having two properties: id and op
Exactly!
the ids I am able to send in the onClick function. But I can't send the inputs together. How do I do?
I tried using formGroup but it didn't work
You should setup multiple formgroups of two inputs: the first one with readonly attribute.
They should be part of a formarray.
In anoher formaraay you should put the checkbox, responsible of toggling disabled property to aforementioned formgroups by their index into the array.
like that? ts this.form = new FormGroup({ op: new FormControl(this.data.op, [ Validators.required, Validators.pattern("^[0-9]*$"), Validators.maxLength(20), ]) });
Can you setup a minimal stackblitz with some fake data?
ofcourse!
It lacks ICertidao interface definition
ICertidao.json is the data