我正面临一些问题。我需要使用Angular.js将动态值分配给属性。我在下面解释我的代码。如何使用Angular.js将动态变量分配给属性
<div ng-repeat="mul in mulImage">
<a ng-href="attchImage{{$index}}" data-spzoom data-spzoom-width="400" data-spzoom-height="400"></a>
</div>
这里我想分配一些链接到控制器端的锚标签。我在下面解释我的代码。
$scope.onLInkSelect = function(index) {
atchVar='attchImage'+ index;
$scope[atchVar]="http://localhost/test/abc.jpg";
}
这里index
参数包含值0,1,2,3,4....
。在这里按expected.Please帮我解决这个问题,我不能得到的结果。
在'NG-href'不插的方式,你似乎是假设的内容。考虑以下内容:'some text'(只有'link'部分被内插。)另外,由于您已经在遍历一个数组,所以为什么不使用它呢?即:'ng-href =“{{mul.link}}”' – ippi
由于代码不起作用,它必须告诉它意味着什么。现在它什么也没有显示。你想让它显示给用户什么?你想如何与用户进行互动? – georgeawg