首页 > 解决方案 > 无法正确从角度编辑器获取内容

问题描述

我有这样的问题。我正在制作一个角度应用程序。在那里我放了角度编辑器。

这是我在其中嵌入了角度编辑器的特定 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 标签,只删除数据库中的数据吗?

谢谢你!!!

标签: angular

解决方案


推荐阅读