0

In translate json i have something like this

"Take": "The '<b>{{Name}}</b>' is assigned to user <b>{{user}}</b> until <b>{{Date}}</b>"

But when i try something like this in html

<p [innerHTML]="'Take' | translate: '{ Name: options.Name, user: options.user, Date: options.date }'">
</p>

And object

options = {
Name: John,
user: Rambo,
Date: 22/02/1997
}

I got this error ERROR SyntaxError: Wrong parameter in TranslatePipe. Expected a valid Object, received: I dont know where I am taking this wrong?

1
  • <p innerHTML="{{'Take' | translate: {' Name': options.Name, 'user': options.user, 'Date': options.date } }}"> </p> Commented Sep 26, 2019 at 12:23

2 Answers 2

5
translate: '{ Name: options.Name, user: options.user, Date: options.date }'

Means your sending a string.

Try with

translate: { Name: options.Name, user: options.user, Date: options.date }
Sign up to request clarification or add additional context in comments.

Comments

0
<p [innerHTML]="'Take' | translate: { Name: options.Name, user: options.user, Date: options.date }">

is the right syntax.

I was confused with it sometimes too. Below is a more complicated usage case. Share here, in the case later you may need.

[attr.aria-label]="(_variable1$ | async) ? ('translateVariable' | translate: { translateProperty: _variable2 }) : ''"

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.