{{ title }} How do I " /> {{ title }} How do I " /> {{ title }} How do I "/>

Inject a translated string as an input in an angular 5 component

2.7k Views Asked by At

I have an angular component template I want to inject title as an @Input() into, to be displayed as:

  <div class="title" >
    {{ title }}
  </div>

How do I inject the translated title into the parent component using ng2-translate's pipe, like so:

<title-component
    [title]="{{ 'KEY' | translate }}"
></title-component>

I want to pass the translated string dynamically to the child component, but I'd prefer to avoid injecting the translate service into the component's constructor and keep everything in the template, if possible. Thanks

1

There are 1 best solutions below

0
Thor Jacobsen On BEST ANSWER

{{}} are not required in inputs, so removing those should solve your issue