1

I was trying to update the image being displayed after an image file with same name overwrote the previous file and came across this link:Reload/refresh an element(image) in jQuery

I had a scope element "imgUrl" which I was passing in the data-ng-src as:

<img data-ng-src="{{imageUrl + '?' + GetTimeStamp()}}">

This thing worked but I also tried this:

<img data-ng-src="{{imageUrl}} + '?' + {{GetTimeStamp()}}">

And this didn't work. Whats the difference between these two expressions?

1 Answer 1

3

The opening brackets {{ indicate that an angular expression begins, and the closing brackets }} indicate that it ends. Everything outside of the brackets is considered to be a plain text attribute. Therefore, the + becomes just a text symbol between the two expressions, rather than acting as the string concatenation operator.

Sign up to request clarification or add additional context in comments.

5 Comments

"Everything, that follows the closing brackets" - to be precise, it's "everything outside of {{ }}"
@SergioTulentsev You are right, that was rather ambiguous, since anything can follow the brackets. Edited the answer. Thank you!
@Kazimieras And if I hadn't used + and just this: {{imageUrl}}?{{GetTimeStamp()}}. Had it been fine?
@VishalChugh This is also fine. In this case you are just evaluating two simpler expressions instead of a more complex one.
@VishalChugh if you find that your question has been answered, it would be great if you could mark it as accepted :)

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.