angularjs - How to return forEach in AngularJS?
问题描述
I'm new to AngularJS and I can't fix one problem. I have value
, which stores multiple numbers. I want to use the numbers as part of URL however I don't know how to make forEach loop.
this is my code:
angular.module('eOpti.app.tasks').controller('packsController', [
'$scope', '$http', '$stateParams', 'breadcrumb',
function ($scope, $http, $stateParams, breadcrumb) {
breadcrumb.data = [{
name: 'Pakiety'
}];
$scope.renderers={
właściwości:function(value, row){
value.forEach(value, function(val){
return '<img src="http://192.168.1.215/img/task/pack/' + val + '.png" style=width:44px;margin-right:3px>';
})
}
}
}]);
I want to create val
from value
but doing something wrong.
解决方案
没有办法停止或中断 forEach(),你必须使用 for 循环,如果你想使用 foreach,请像 >>>
value.forEach(function (item) {
item.src = 'http://192.168.1.215/img/task/pack/'+item.val+'.png'
});
并在 img 标签中使用 ng-src={{item.src}}
推荐阅读
- arrays - Powershell - 从数组中选择名称并将电子邮件发送到 DL
- pandas - 如何基于行子集进行滚动计算
- javascript - 刷新页面后,如何确保从 localStorage 显示正确的数据?
- mysql - 连接失败 mySQL for Excel 1.3.8
- python-2.7 - Revit API Python SetBoxCenter() 应用于多个视口
- wordpress - 神秘的 WordPress 问题——想不通
- javascript - 如何通过使用前面的数字来减小字符串的大小?
- flutter - Flutter AnimatedOpacity 在发布模式下变灰?
- node.js - 如何在 node.js 中禁用 process.stderr?
- ios - Cocoapods 安装 Parse SDK 的 release 而不是 master 分支