0

I want to concat different variables but I am getting parse error;

Parser Error: Got interpolation ({{}}) where expression was expected

Is there any way to concat a binding variable like below?

<ng-template let-item="item">
    <input type=text [src]="myObject.urls.{{item.id}}">
</ng-template>

EDIT: What I want to get is like;

<input type=text [src]="myObject.urls.33322222">

I got an object;

myObject = {urls: {33322222: "someUrlValue"}};
1
  • [src]="'myObject.urls.' + item.id" or src="myObject.urls.{{item.id}}"? Commented May 9, 2018 at 15:04

1 Answer 1

3

You can use square brackets to access computed object properties:

<input type=text [src]="myObject.urls[item.id]">
Sign up to request clarification or add additional context in comments.

Comments

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.