2

I have a template string that evaluates an Observable:

<button [title]="filterButtonText">
      {{ selectedUsers$ | async | delimiter:"|"}}
</button>

The delimiter pipe converts the string to "User1|User2" etc. I want to use the same value in the title property like :

<button [title]="{{ selectedUsers$ | async | delimiter:"|"}}">
      {{ selectedUsers$ | async | delimiter:"|"}}
</button>

But this doesn't seem to work. I want to reuse the output of {{ selectedUsers$ | async | delimiter:"|"}} in the title property. How can I do it? Or is there is a better of the way of achieving this without re-evaluating the observable?

EDIT

<button [title]="selectedUsers$ | async | delimiter:'|'">
  {{ selectedUsers$ | async | delimiter:"|"}}
</button>

Removing {{ }} worked. But another question, is there a way I can evaluate this in one place ? Without having the same statement in two places ?

0

1 Answer 1

1

You can reuse the title of the button to set its content, with the help of a template reference variable:

<button #btn [title]="selectedUsers$ | async | delimiter:'|'">
  {{ btn.title }}
</button>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Precisely what I was looking for.

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.