I have an Angular app where I am looping through a collection. I am using a classic for loop, but for like to use something more up to date. underscore.js is already included in the project, and I took a look at using _.each
This is my current (working) js code:
Batches.create($scope.newPanel).then(function(panel) {
console.log('panel created: ' + panel.id);
for(i = 0; i < $scope.selector.tabledata.length; i++){
createPanelDetails(panel.id, $scope.selector.tabledata[i]);
}
I would like to use the _.each, but how do I pass in the panel.id variable as I do with the for loop?
_.each($scope.selector.tabledata, createPanelDetails(panel.id ??, iterator???);
Or should I be using some other method from underscore to achieve this?