Error: Template parse errors:
'center' is not a known element:
1. If 'center' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
[ERROR ->]<center><h2>my-candid works!</h2>
<div [style.color]="isSpecial ? 'red' : 'green'">This is style bi"): ng:///AppModule/MyCandidComponent.html@1:2
最佳答案
您只是想将文本居中吗?
<h2 [ngStyle]="{'text-align': 'center'}">my-candid works!</h2>
或者将 div 居中,您始终可以使用 CSS,例如:
.yourDiv {
margin: 0 auto;
}
关于angular - Angular 中 <center> 的替代品是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46367201/