无法正确地从角度编辑器获取内容

时间:2018-07-01 10:58:43

标签: 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标记,而仅删除数据到数据库吗?

谢谢!

0 个答案:

没有答案