I have tried to bind dynamic font-family to text. But I face a problem that a font name start with a number cannot be bind to DOM element. I've done a lot of research but I cannot find why it happens.
Template:
<h2 [style.font-family]="font">Hello {{name}}</h2>
Component class:
constructor() {
this.name = `Angular! v${VERSION.full}`;
this.font = '28 Days Later';
}
With font "Arial", DOM generate fine:
But, it seems to ignore generating font "28 Days Later"
Here is Plunker
I appreciate any suggestion, thanks in advance!
这很简单,只需像这样使用您的字体:
this.font = "'28 Days Later'";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.