http://plnkr.co/edit/m8m2I9dqE2kF1H1nzxJT?p=preview
$scope.links = [
{'link':'www.google.com'},
{'link':'www.ask.com'},
{'link':'www.yahoo.com'}
];
$scope.openLinks = function(){
var urls = '';
angular.forEach($scope.links, function(){
$window.open("link.html/?" + $scope.links.link);
});
};
我想循环遍历一个数组并在新窗口中打开它们但我未定义。
答案 0 :(得分:4)
从角度文档中,forEach的工作原理如下:
angular.forEach($scope.links, function(link, key) {
$window.open("link.html/?" + link);
});
答案 1 :(得分:2)
这应该解决它:
angular.forEach($scope.links, function(item){
$window.open("link.html/?" + item.link);
});