Issue
I need to show an input once the "maintenance" (manutenção in br) option is selected in the dropdown, what is wrong? I think I'm on the right path but there's something that's not right...
html:
<div class="col-xl-4 col-lg-4 col-md-6 col-sm-12 col-12 mt-2">
<div class="form-group">
<label>Status da instalação</label>
<p-dropdown
[filter]="true"
[options]="installationDeviceStatus"
[(ngModel)]="labelSelected"
[style]="{ width: '100%' }"
autoWidth="false"
formControlName="installation_status"
></p-dropdown>
</div>
</div>
<div
class="col-xl-4 col-lg-4 col-md-6 col-sm-12 col-12 mt-2"
*ngIf="labelSelected == 'Manutenção'"
>
<div class="form-group">
<label>Motivo da Manutenção</label>
<input
class="form-control"
formControlName="maintenance"
readonlyDisable
type="text"
placeholder="Digite aqui o motivo"
/>
</div>
</div>
ts:
public installationDeviceStatus = [
{
label: "Em Operação",
value: "em operacao",
},
{
label: "Fora de Operação",
value: "fora de operacao",
},
{
label: "Com Defeito",
value: "com defeito",
},
{
label: "Manutenção",
value: "manutencao",
}
];
labelSelected: string = "Manutenção";
Solution
You should access obj labelSelected
propery e.g label
to compare with string Manutenção
. Right now your trying to compare if obj {}
equals Manutenção
(no it does not).
<div class="col-xl-4 col-lg-4 col-md-6 col-sm-12 col-12 mt-2"
*ngIf="labelSelected.label === 'Manutenção'" >
Answered By - Joosep.P
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.