I am facing some problem.I need to assign the dynamic value to attribute using Angular.js . I am explaining my code below.
<div ng-repeat="mul in mulImage">
<a ng-href="attchImage{{$index}}" data-spzoom data-spzoom-width="400" data-spzoom-height="400"></a>
</div>
Here i am trying to assign some link to the anchor tag in controller side. I am explaining my code below.
$scope.onLInkSelect = function(index) {
atchVar='attchImage'+ index;
$scope[atchVar]="http://localhost/test/abc.jpg";
}
Here index
parameter is containing the value 0,1,2,3,4....
.Here i can not get the result as per expected.Please help me to resolve this issue.
ng-href
is not interpolated the way you seem to be assuming. Consider the following:<a ng-href="http://example.com/{{link}}">some text</a>
(only thelink
part gets interpolated. ) Also since you are already iterating through an array, why not use that? i.e:ng-href="{{mul.link}}"
– ippi 2 days ago