angular - 无法正确从角度编辑器获取内容
问题描述
我有这样的问题。我正在制作一个角度应用程序。在那里我放了角度编辑器。
这是我在其中嵌入了角度编辑器的特定 component.html。
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<body class="fixed-nav sticky-footer bg-dark" id="page-top">
<!-- Navigation-->
<app-adminnavbar></app-adminnavbar>
<div class="content-wrapper">
<div class="container-fluid">
<form (submit)="putNews()">
<app-ngx-editor [placeholder]="'Enter text here...'" [spellcheck]="true" name="htmlContent" [(ngModel)]="htmlContent" minHeight="50px" Width="50px" ></app-ngx-editor>
<br>
<button type="submit" class="btn btn-success">Post News</button>
</form>
</div>
<app-adminfooter></app-adminfooter>
<a class="scroll-to-top rounded" href="#page-top">
<i class="fa fa-angle-up"></i>
</a>
</div>
</body>
这是我的特定 component.ts 文件。
import { Component, OnInit } from '@angular/core';
import { BootstrapAlertService, BootstrapAlert } from 'ngx-bootstrap-alert';
import { NewsService} from '../../shared/news.service';
import {News} from "../../shared/news";
@Component({
selector: 'app-news',
templateUrl: './news.component.html',
styleUrls: ['./news.component.css'],
providers: [NewsService]
})
export class NewsComponent implements OnInit {
public news:News = new News();
htmlContent: any;
constructor(private newsService: NewsService,private bootstrapAlertService:BootstrapAlertService) { }
ngOnInit() {
}
putNews(){
this.news.content=this.htmlContent;
this.newsService.putNews(this.news).subscribe((res)=>{
this.bootstrapAlertService.alert(new BootstrapAlert("Succesfully Post a news!", "alert-success"));
});
}
}
当我将它发送到数据库时,它会发送 div 标签和所有 HTML 元素。Somone 可以帮我删除那些 HTML 标签,只删除数据库中的数据吗?
谢谢你!!!
解决方案
推荐阅读
- autohotkey - 获取组合框以显示 ar 列出,未排序
- arrays - Google GeoChart(Lavacharts 库)-> AddRow / AddRows 未在地图上呈现任何结果,尽管创建了值数组
- git - 执行 git apply 时出现错误“删除 1 个前导路径名组件时 git diff 标头缺少文件名信息”
- azure-active-directory - OIDC 应用程序日志记录
- html - 我可以在媒体查询中包含和排除 html 文本吗?
- javascript - 如何限制“FileUploadBox()”按钮的数量?
- c# - 只使用一份请愿书而不是多份
- node.js - 使用猫鼬将上传的图像名称保存在数组中
- javascript - 如何根据用户输入计算多个地点的旅程燃油价格
- sql-server - 触发器存在但未显示在服务器对象、数据库触发器或表下的触发器文件夹中