0
When you select the 'title' item it is to hide the input. But when I select another item from another ngFor index, the input selected 'title' is displayed again. Example
0
When you select the 'title' item it is to hide the input. But when I select another item from another ngFor index, the input selected 'title' is displayed again. Example
2
The problem is that you are doing this with a whole type variable:
idvalue = 0;
To solve your problem, create an array to receive the value of each line:
idvalue = [];
And change your method:
changeValue(event, index) {
console.log(event, index);
this.evento = event === index + '_title';
this.idvalue = index;
}
To:
changeValue(event, index) {
this.idvalue[index] = event.includes('title') ? index : -1;
}
This way we check if the selected option is "title" and assign the value at the position of the array corresponding to the line you want to hide the field.
And finally you no longer need the "event" option in your input:
<input [hidden]="i === idvalue[i]" id="id_{{i}}" name="name_{{1}}" type="text" value="">
Browser other questions tagged javascript angular typescript angular-8
You are not signed in. Login or sign up in order to post.
Got it! Thanks for the details in the explanation. It worked perfectly!
– Rafael Tavares