Here’s an Angular feature that’s incredibly useful for handling events triggered by an input element inside a ng-repeat.
Gathering input from a user from an radio button inside an ng-repeat has its difficulties, and there’s hardly any documentation for it. So I’ve broken it down here, and wanted to share it with y’all. The key is to be able to access the variable created in the ng-repeat from your template (i.e. report in the ng-repeat ‘report in allReports’ from the example below)?
The first thing we need to do is assign ng-model to the
$parent object. In our case it would be
$parent.report and assign it a name attribute. We also want to assign that variable name (i.e.
report) to ng-value.
In our controller then, the contents of this variable are accessible by name. In our case we can gather the data of this particular
Hope that helps! Let me know if you have any questions! Thank you.