javascript - Ng-Repeat showing irregular behavior with one time binding -
i having ng-repeat directive running on array on object. facing specific scenario in which, when bind object properties 1 time binding getting refreshed when purge , add data in array of object on running ng-repeat.
the point focus here is, these functionalities working previosuly.
code
<div class="search_result" data-ng-repeat="prod in searchresult track $index" ng-show="showwhenresultpositive"> <div class="media search-result-container"> <div class="media-left"> <div class="left "> </div> <div class="leftbottom"> </div> <div class="righttop"> </div> <div class="rightbottom"> </div> <div class="searchimg_container" ng-click="redirectiontopage(prod.url)"> <!--<img src="{{prod.tkh_imageurl}}" alt="not available" class="lazyload"/>--> <picture> <source data-srcset="{{prod.desktopimage}}" media="(min-width: 768px)"> <source data-srcset="{{prod.mobileimage}}" media="(min-width: 320px)"> <img src="data:image/gif;base64,r0lgodlhaqabaaaaach5baekaaealaaaaaabaaeaaaictaeaow==" data-src="${properties.placeholderimage}" alt="not available" class="lazyload"><!--${properties.placeholderimage}--> </picture> </div> </div> <div class="media-body search-desc"> <p ng-if="ispdf" class="subheading" ng-click="redirectiontopage(prod.url)">{{::prod.title}}</p> <p ng-if="!ispdf" class="subheading" ng-click="redirectiontopage(prod.url)">{{::prod.tkh_title}}</p> <p ng-if="!ispdf" class="resultdesc">{{::prod.tkh_description}}</p> </div> </div> </div>
here code same.
from docs:
avoid using
track $index
when repeated template contains one-time bindings. in such cases,nth
dom element matchednth
item of array, bindings on element not updated when corresponding item changes, causing view out-of-sync underlying data.
if working objects have unique identifier property, should track identifier instead of object instance. should reload data later, ngrepeat
not have rebuild dom elements items has rendered, if javascript objects in collection have been substituted new ones. large collections, improves rendering performance.
Comments
Post a Comment