george george - 3 months ago 6x
AngularJS Question

javascript/angularjs: when opening the modal i do not get the desired data

i am updating a SPA but i have a problem i want to display the name of the classes but nothing appears
here is the code where i have a problem with maybe i am missing something:

$ = function (classes) {
var modalInstance = ${
templateUrl: 'classes.html',
controller: 'ModalClassesInstanceCtrl',
resolve: {
info: function () {
var info = {};
$log.warn("classes info",info);
return info;

what i got in console


show that i have 5 classes like this

classes [Object, Object, Object, Object, Object]

if i click on any object it shows all the data about that object including the class name for example clicking the first object will show the following data

1: Object $$hashKey: "object:13" id: 4 level: "4" name: "fox" year: "2015/2016"


$"classes info",info);

only show class info Object {name: undefined}

please can u check weather i have something wrong in this code


Look carefully at this line: info['name']=;. classes is an array of objects, not an object with name property - that's why you get undefined. If you want to display a class name, you need to refer to an object inside an array, e.g. classes[0].name. If you want to display all classes' names, you should iterate over them and join the names into one string.