Task:
Build a utility function to build a configurable URL. The URL pattern looks like that
/images/<size>/users/<user_id>
Possible Solutions
1. Build a directive. It could look like follows:
<img my-user-img my-size="small" my-user="4711" />
This is a little bit ugly since I have to add all the boilerplate to support multiple arguments.
2. Build a util/helper function. It could look like follows:
<img ng-src="{{userImg('small', '4711')}}" />
This is ugly since I have to bind the function to $rootScope
in order to use it everywhere .
The Question
Which solution is the closest to Best Practice and why? :D