4

Using interpolation to set a property works with this code:

This work for me.
<span *ngFor="let car of Car; let i = index;" >
<img src="car/{{car.id}}">
</span>

but it does not work using property binding like this:

<span *ngFor="let car of Car; let i = index;" >
<img [src]="car/car.id">
</span>

What should I do?

0

1 Answer 1

7

You can use the following syntax for property binding:

[src]="'car/' + car.id"
Sign up to request clarification or add additional context in comments.

2 Comments

Interpolation is not used for property binding since it is already implied.
@蒋建雨 - Feel free to mark the answer as accepted (with the green check mark) if it provides a solution to your question.

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.