ProgramingTip

Angular 4+에서 html 태그로 사용되는 방법은 무엇입니까?

bestdevel 2020. 10. 16. 07:45
반응형

Angular 4+에서 html 태그로 사용되는 방법은 무엇입니까?


이 질문에 이미 답변이 있습니다.

내 각도 4 앱에는 다음과 같은 곳이 있습니다.

comment: string;
comment = "<p><em><strong>abc</strong></em></p>";

이 텍스트를 내 html로 제공하면

{{comment}}

그러면 다음이 표시됩니다.

<p><em><strong>abc</strong></em></p>

하지만 같은 굵은 기울임 꼴 형태로 텍스트 "ABC"를 표시해야 ABC

어떻게 할 수 있습니까?


단방향 흐름 구문 속성 바인딩 사용 :

<div [innerHTML]="comment"></div>

참고 URL : https://stackoverflow.com/questions/49013217/how-to-render-string-with-html-tags-in-angular-4

반응형