Angular 2 : Escape character in component's input

标签 angular

我有以下代码:

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

我已经尝试了很多东西('', \', \\', \'' , ...) 来转义 ' ,但我没能做到。 我该怎么做?

最佳答案

title 似乎是一个组件属性,因此它需要一个变量或字符串。我假设正确的语法是:

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

前后加单引号

关于 Angular 2 : Escape character in component's input,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40383532/

相关文章:

angular - CORS 错误,但仅限于 URL 中存在特殊字符

angular - 如何创建 Angular 旋转器

子组件中的 Angular 2+ 验证

Angular 6 - CSS - STICKY 标题

typescript - Angular 2 路由器、href 链接和不需要的页面刷新

javascript - 如何共享变量并跟踪 Angular v4 ts 中多个组件的变化

Angular 2通过输入更改类中的变量

angular - 在 npm 中安装新依赖项时 RXJS 版本不匹配

angular - 语法错误 : Unexpected token < in JSON at position 0 at

javascript - Angular 应用程序中的 event.stopPropagation() 导致 jasmine 超时