I have a list of varieties generated by a for loop. Each item in that list has a button beside it so that particular list item can be deleted. Each button will open up a modal where you confirm whether or not you want to delete that variety. I don't want an unlimited amount of modals on the page, so I put the modal outside of the for loop and want to pass the id from the initial delete button to the modal so the modal knows which variety to delete. I figure in order to do that, I need to create a variable. I attempted this by putting #varietyToDelete="{{variety.PerProjectVarietyId}}" in the initial delete button, and then inside of the final delete button in the modal, I added this: (click)="removeVariety(#varietyToDelete)"
For a better look at my code, here is the relevant part of a for loop that I have:
<div *ngFor="let variety of varieties; let i=index">
...
<div class="varietyName">
<a href="#deleteVarietySelling" #varietyToDelete="{{variety.PerProjectVarietyId}}" data-toggle="modal">
<i class="fa fa-minus"></i>
</a>
</div>
</div>
</div>
And here is my modal, where I want to pass that variable to:
<div class="modal fade alert" id="deleteVarietySelling" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<a href="#" class="close-modal" data-dismiss="modal">×</a>
<p class="confirmation-message">
Are you sure you want to delete this variety?
</p>
<div class="row">
<div class="removeCancel">
<a href="#" class="cancel-button" data-dismiss="modal">Cancel</a>
<a href="#" class="remove-button" (click)="removeVariety(#varietyToDelete)">Remove</a>
</div>
</div>
</div>
</div>
</div>
</div>
When I try this, I get the following error:
There is no directive with "exportAs" set to "{{variety.PerProjectVarietyId}}"
Is there a way to get what I'm trying to do to work? Is my syntax off, or do I need to take a different approach entirely?
#varietyToDelete="{{variety.PerProjectVarietyId}}"should be#varietyToDelete="variety.PerProjectVarietyId"(click)="removeVariety(#varietyToDelete)should be(click)="removeVariety(varietyToDelete), but I'm not 100% sure that's gonna work. Give it a shot and let us know.