0

In an angular template, how can I evaluate what of this two options is better?

  1. <img ng-src="{{filteredImgs[imgIdx].signed_src}}&width=1000">

  2. <img ng-src="{{filteredImgs[imgIdx].signed_src + '&width=1000'}}">

I would like to see if there are differences when dealing with errors, or performance implications between both alternatives, but I could not find the source of where those two are evaluated. (I suspect this is in angular template evaluation core)

jperelli
  • 6,988
  • 5
  • 50
  • 85
  • I don't see how they can be different, but `ng-src` is interpolated with a watcher [`$observe`](https://stackoverflow.com/questions/14876112/angularjs-difference-between-the-observe-and-watch-methods), which is invoked whenever the interpolated value changes (in your case it's `filteredImgs[imgIdx].signed_src`) whether it is concatenated with some string or not – Aleksey Solovey Feb 14 '18 at 14:10
  • Then maybe one is better than the other in that one is more "elegant" code? – jperelli Feb 14 '18 at 20:35

0 Answers0