我试图在下面的.html(模板)中实现angular4 (下面的代码),如何处理多个括号和大括号并修复这个错误?
But getting error as:-
ERROR Error: Uncaught (in promise): Error: Template parse errors:
Unexpected character "EOF" (Do you have an unescaped "{" in your template? Use "{{ '{' }}") to escape it.) ("
app.component.html
<div>
<code>
<pre>
@Component({
selector: 'app-projection',
templateUrl: './projection.component.html',
styleUrls: ['./projection.component.css']
})
</pre>
</code>
</div>
发布于 2018-08-13 12:11:50
正如错误信息所表明的那样,
意料之外的字符"EOF“(模板中是否有未转义的"{”)?使用"{{‘{}“)来转义它。) (”
确保在您的{字符之前添加了一个‘(引号),您应该将代码修改为,
<div>
<code>
<pre>
@Component({{ '{' }}
selector: 'app-projection',
templateUrl: './projection.component.html',
styleUrls: ['./projection.component.css']
})
</pre>
</code>
<div>
希望这能有所帮助!
发布于 2018-08-13 12:38:34
编辑
为什么要在HTML中声明“内联”组件?
您应该在一个单独的文件中声明一个组件,然后使用选择器在HTML中使用它
例如:
<pre>
<app-your-component-selector></app-your-component-selector>
</pre>
原始
错误是暗示您的HTML中有一个额外的{,可能是这样的。
<div> { --This will cause the error </div>
<div> { {{'This too'}} </div>
<span id="{{maybeHere}"> </span>
https://stackoverflow.com/questions/51822004
复制相似问题