To access locfrnd
in the code snippet below, follow these steps:
I have created an Array named PlaceCollection
containing 2 elements.
place
locfrnd
, which is an array
While I was able to successfully access place
, I encountered an error when trying to access locfrnd
.
var ctry = $scope.country;
var frnds = [];
angular.forEach($scope.Friend, function (friend) {
var eachFriend = {
name: friend
};
frnds.push(eachFriend);
});
var record = {
place: ctry,
locFrnd: frnds
};
$scope.placeCollection.push(record);
//The issue arises with the following code resulting in 'object object' alerts
for (var j = 0; j < $scope.placeCollection.length; j++) {
alert($scope.placeCollection[j].locFrnd);
}