简体   繁体   中英

angular component html is escaping my superscript character

I have some text, in an angular 5 component as follows.

Area Breakdown m²

Unfortunately angular is breaking my neat little squared character and displaying this:

Area Breakdown m²

component.ts

@Component({
    templateUrl: `component.html`
})
export class SourceDocumentWorkItemsComponent implements OnInit {
    // (all very standard)
}

component.html

<div class="input-group">
    <label class="bold">Area Breakdown m&sup2;</label>
</div>

How do I stop angular from mangling my html... I am pretty sure angular is the culprit here.

Try [innerHTML] instead as below it gives the output as per your requirement:

areaBreakdownText:string='Area Breakdown m&sup2;';
<label class="bold" [innerHTML]="areaBreakdownText"></label>

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM