简体   繁体   中英

$index in ng-repeat not getting replaced angularjs

i am using ng-repeat to populate a image list. i need to use $index for naming the images and use it for replacing src of preview div. $index is not replacing in mouseover section while its getting replaced in name section. what can be the reason and how to correct it.

<img onmouseover="preview.src=img{{$index}}.src" name="img{{$index}}" src="{{image.SMALL_PATH}}" alt="" ng-repeat="image in images | filter:query"/>



<div class="preview" align="center">
    <img name="preview" src="images/img1.jpg" alt=""/>
</div>

使用ng-srcng-mouseover您的代码段将是

<img data-ng-mouseover="preview.src=image.src" name="image.name" data-ng-src="image.SMALL_PATH" alt="" ng-repeat="image in images | filter:query"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM