我试图从父项组件向我的子项目组件传递一个字符串。该字符串包含html标签和一个html实体。这是在父模板的一个例子:从父项到子项传递带有html标记的字符串
<child-component i18n-componentContent="this is a test|for testing" componentContent='my test<sup>®</sup>not working'></child-component>
的子组件方面,我有以下几点:
@Input() public componentContent: string;
...
public ngOnInit() {
console.log(this.componentContent);
}
然而,
this.componentContent
是价值: "my test"
因此,并不是将整个字符串传递给子组件。为什么不是将整个字符串传递给子组件? 我需要做什么才能将整个字符串从父项传递给子组件?
感谢您的回应,但i18n-componentContent是必要的我传递给子组件的字符串本地化,它不应该与要传递的字符串有任何关系。 – Sean12
令人惊讶的是,删除i18n标签确实解决了问题,并且完整的字符串被传递给了子组件,但是我不能对字符串进行本地化,因为不再有i18n属性。这在我看来是Angular 4+模板引擎的一个缺陷。 – Sean12