Reputation: 397
is says i is undefined in line url: data.url[i]
??
$scope.data = [{
"url":"http://www.google.com"
},
{
"url":"http://www.bing.com"
},{
"url":"http://www.yahoo.com"
}];
angular.forEach($scope.data, function(data){
//var links = data.url;
console.log(data);
//I need array to be use in
chrome.tabs.create({
url: data.url[i]
});
});
Upvotes: 0
Views: 32
Reputation: 5290
You don't need i
at all. data
already refers to the individual item.
angular.forEach($scope.data, function(data){
chrome.tabs.create({
url: data.url
});
});
Although to avoid confusion, you might want to use a parameter name other than data
in the forEach
function, since your $scope variable is also named data
.
angular.forEach($scope.data, function(item){
chrome.tabs.create({
url: item.url
});
});
Upvotes: 1