0
I’m having trouble passing parameters to my Modal, I would like to present the data of the selected tuple, I was able to isolate the value properly (atestei by the console.log), however, this same one is not being passed to my modal, looks like it would need something like an asynchronous call, even if every operation takes place inside my front (doesn’t make a new bank call).
The intention is to make a form, however, just to verify that the data are being passed properly, I will use the simple passage of my JSON, solving this would be great to continue.
Filter code:
filtrardetalhes(value){
this.planilhaDetalhes = this.planilha.filter(x =>
x.PID == value
);
console.log(this.planilhaDetalhes)
}
Modal:
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" (click)="filtrardetalhes(planilha.PID)">
Details
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<img src="assets/Detalhes.png" width="25px"/>
<h5 class="modal-title" id="exampleModalLabel"> Detalhes </h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
{{planilhaDetalhes}}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" (click) = "AtualizaBtn()">Save changes</button>
</div>
</div>
</div>
</div>
I put an "Input" in my variable "Spreadsheet" but only for test purposes:
@Input('planilhaDetalhes') public planilhaDetalhes
How the parameter is being passed:
It is worth mentioning that the filter is functional, I only left my JSON closed because it contains confidential business information, however this 1 position JSON is the filter of a 74 (and it accompanies where I click on DETAILS)
EDIT:
Solved, I passed the JSON in its entirety, however, I am in doubt if I can pass any specific parameter, for example{{planilhaDetalhes.CAMPO | JSON}}
Follow as the passage to my form:
Functional form (unable to pass parameters yet) within BODY MODAL:
<form class="meuFormulario" [formGroup]="cadastroForm" (ngSubmit)="onSubmit()">
<div class="form-group">
<label for="exampleInputEmail1">Cliente</label>
<input type="text" class="form-control" formControlName="CLIENTE" value="{{planilhaDetalhes.PID}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">CODIGO DMD</label>
<input type="text" class="form-control" formControlName="CODIGODMD" value="{{planilhaDetalhes.CODIGODMD}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Sigla RM</label>
<input type="text" class="form-control" formControlName="SIGLARM" value="{{planilhaDetalhes.SIGLARM}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Sigla Portal</label>
<input type="text" class="form-control" formControlName="SIGLAPORTAL" value="{{planilhaDetalhes.SIGLAPORTAL}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Comercial</label>
<input type="text" class="form-control" formControlName="COMERCIAL" value="{{planilhaDetalhes.COMERCIAL}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Atendimento</label>
<input type="text" class="form-control" formControlName="ATENDIMENTO" value="{{planilhaDetalhes.ATENDIMENTO}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Auditoria</label>
<input type="text" class="form-control" formControlName="AUDITORIA" value="{{planilhaDetalhes.AUDITORIA}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Periodicidade</label>
<input type="text" class="form-control" formControlName="PERIODICIDADE" value="{{planilhaDetalhes.PERIODICIDADE}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Entrega</label>
<input type="text" class="form-control" formControlName="ENTREGA" value="{{planilhaDetalhes.ENTREGA}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Responsável</label>
<input type="text" class="form-control" formControlName="RESPONSAVEL" value="{{planilhaDetalhes.RESPONSAVEL}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Layout</label>
<input type="text" class="form-control" formControlName="LAYOUT" value="{{planilhaDetalhes.LAYOUT}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">DM</label>
<input type="text" class="form-control" formControlName="DM" value="{{planilhaDetalhes.DM}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">ODSDM</label>
<input type="text" class="form-control" formControlName="ODSDM" value="{{planilhaDetalhes.ODSDM}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">EFV</label>
<input type="text" class="form-control" formControlName="EFV" value="{{planilhaDetalhes.EFV}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Caminho</label>
<input type="text" class="form-control" formControlName="CAMINHO" value="{{planilhaDetalhes.CAMINHO}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Origem</label>
<input type="text" class="form-control" formControlName="ORIGEM" value="{{planilhaDetalhes.ORIGEM}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Comercial</label>
<input type="text" class="form-control" formControlName="COMERCIAL" value="{{planilhaDetalhes.COMERCIAL}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Portal</label>
<input type="text" class="form-control" formControlName="PORTAL" value="{{planilhaDetalhes.PORTAL}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">FTP</label>
<input type="text" class="form-control" formControlName="FTP" value="{{planilhaDetalhes.FTP}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Observação</label>
<input type="text" class="form-control" formControlName="OBSERVACAO" value="{{planilhaDetalhes.OBSERVACAO}}">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Mailing</label>
<input type="text" class="form-control" formControlName="MAILING" value="{{planilhaDetalhes.MAILING}}">
</div>
<div class="form-group">
<label for="exampleFormControlSelect1">Example select</label>
<select class="form-control" id="exampleFormControlSelect1">
<option>Produção</option>
<option>Other</option>
</select>
</div>
</form>
</div>
So it was very confusing your question, you have the function filtration() that is not being executed anywhere.
– LeAndrade
Sorry, I forgot to include the part of the call, edited with it included now!
– Franco Genaro
And what would be spreadsheet.?
– LeAndrade
The ID, this is coming from my INPUT for Ngfor which builds the initial table (where the detail button, which opens the modal stays), the filter is functional, the problem I am facing would be in passing parameters to my modal.
– Franco Genaro
Apparently it filters after opening the modal, so the modal only gets "Object Object" from my variable.
– Franco Genaro
change
{{planilhaDetalhes}}
for{{planilhaDetalhes | json}}
– Gaspar
Solved! Good Gaspar! Thank you very much!
– Franco Genaro
Another question only, I managed to pass the | JSON, but I’m not getting past worksheets.FIELDEXAMPLE | JSON, would have some way to do this?
– Franco Genaro
Could you explain to me the operation of this pipe briefly "|"?
– Franco Genaro
The pipe json (| json) is used to transform the values in the fields. If you want to build a form in this modal, just inform
planilhaDetalhes.CAMPOEXEMPLO
in thengModel
input of this field...– Gaspar
Pipe is basically to visually transform an object that you don’t want to change completely just to show the user in the view. The official documentation of the pipe is here
– Gaspar
Thanks for the information about pipe, it will be very useful! Now the field question, when putting {{worksheet.PID}} in my form, it does not return any value. The only way to return something was {{worksheet | json}}.
– Franco Genaro
I included the form for better understanding
– Franco Genaro
I will edit my reply with the necessary information
– Gaspar
Ok! Put it as an answer below and I will gladly vote for it!
– Franco Genaro
It is edited in the answer! Any doubt let me know
– Gaspar
Is there any other way than with ngModel? It appears that some features of ngModel will be removed/changed in the next versions of the angular, thus being able to compromise my application in case of update.
– Franco Genaro
I did a horrendous gambit with ngFor failed in an example json and it worked
– Franco Genaro
ngModel will never be removed from the 2+ angle, you can use it quietly. If you want to apply a form and control whether it is validated or not, it is used in another way to control the state, but it is the same concept and not very recommended for those who start it. Start using separate objects and validate the essentials, when everything is working, migrate forms with a more robust validation...
– Gaspar