in angularjs modal i am trying to display all classes that have level 4 but i got only one. please how should i alter my could in order to get all the class
$scope.openClass = function (classes) {
$log.info("classes",classes);
var modalInstance = $modal.open({
templateUrl: 'classes.html',
controller: 'ModalClassInstanceCtrl',
resolve: {
info: function () {
var info = {};
for (var i=0;i<classes.length;i++){
if (classes[i].level==4){
info['name']= classes[i].name;
$log.info("classinfo",info);
}
}
$log.info(info);
return info;
}
}
});
the $log in if condition show me the write classes they are two in my case but the $log after the for loop show me only one
varin yourforloop. Without it, it assumes thatiis a global variable. And if using anyway in the script anothervariable namedi, you'll have some unexpected results.info[]['name']orinfo['name'].push(classes[i].name