我想知道是否有人知道如何将Markdown-it添加到现有的Angular 8应用程序中。我已经用npm install安装了这个包,但是不知道如何将它导入到我的组件中。有人知道怎么做吗?提前感谢!
发布于 2020-06-21 15:45:07
安装markdown-it
npm i markdown-it
import { Component, OnInit } from '@angular/core';
import md from 'markdown-it';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
private markdown;
outHtml;
constructor(){
this.markdown=md();
this.outHtml=this.markdown.render("# Ahmad Hamzavi");
}
ngOnInit() {
}
}<span [innerHTML]="outHtml" ></span>
https://stackoverflow.com/questions/61553618
复制相似问题