user1762608
user1762608

Reputation: 245

how to combine two angular expressions in ng-src directive

I want to dynamically generate image url in ng-reapeat like this

<img  ng-src="{{baseurl}}+{{category.imageurl}}">

the above code is not working. Please help me how can I do it.

Upvotes: 1

Views: 1652

Answers (2)

Darlan Alves
Darlan Alves

Reputation: 500

Depending on which version of AngularJS you are using, this is expected.

Check this out:

https://docs.angularjs.org/guide/migration#you-can-only-bind-one-expression-to-src-ng-src-or-action-

Upvotes: 0

JB Nizet
JB Nizet

Reputation: 691755

If the + is out of the mustaches, it's not interpretedt at all and ends up being in the attribute value. You just need

{{baseurl}}{{category.imageurl}}

or, better,

{{baseurl + category.imageurl}}

Upvotes: 4

Related Questions