I tried a lot of things...">

Angular2: exit character in component input

I have the following code:

<my-comp [title]="Foo component"></my-comp>

I tried a lot of things ( '', \', \\', \'', ...) to avoid entering ', but I did not succeed. How can i do this?

+4
source share
2 answers

It seems that title is a property of the component, so it expects a variable or string. I assume that the correct syntax would be as follows:

<my-comp [title]="'Foo\ component'"></my-comp>

Add one quotation mark before and after

+4
source

You are attached to a property titlethat is probably of type string. What you are actually doing connects this with a javascript expression (well .. angular2), which Foo component, but this is not a valid expression.

:

  • title , title="Foo Component"
  • : [title]="'Foo\ component'".
+1

Source: https://habr.com/ru/post/1659621/


All Articles