0

I have a scope function that gets called and executed multiple times. How can i avoid this or how can I stop this?

<div class="row">
   <label>Attached Documents</label>        
   <ion-scroll> 
      <img ng-repeat="image in detailedCaseInfo.real_estate_agent_assignment_attachments" ng-src='{{urlForImageDownload(image.filename)}}' ng-click="showImagesDetailed($index)" class="image-list-thumb" height="50px"/>
  </ion-scroll> 
</div>  



$scope.urlForImageDownload = function(imageName) {
    var name = imageName.substr(imageName.lastIndexOf('/') + 1);
    console.log(name)
    console.log(imageName)
    var trueOrigin = AppSettings.baseApiUrl + imageName;
    console.log(trueOrigin)
    return trueOrigin;
  }

I know it has to do something with databinding and $digest but i just cant figure out how to make it not execute multiple times.

Any help is appreciated

1
  • 4
    you have used it with ng-repeat it will be called each time the img tag is created ! Commented Aug 9, 2015 at 19:32

1 Answer 1

1

Your function isn't doing anything that you couldn't do simply using a scope variable for the image paths:

JS

$scope.imagePath = AppSettings.baseApiUrl;

HTML

<img ng-repeat="...." ng-src="{{imagePath + image.filename}}">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.