【发布时间】:2022-12-10 16:54:25
【问题描述】:
我正在研究 angular spring boot 应用程序,所以我想保存一篇包含 html 标签(如链接)的文章。
基本上,我想保存并显示一篇带有链接的文章。我尝试使用带有角度标记的包
下面是保存文章的角度代码:
// # component code
savePost(){
var form = new FormGroup({
meid: new FormControl(this.meid, Validators.required),
text:new
FormControl(marked(this.posttext),Validators.required),
country:new FormControl(this.country,Validators.required),
});
if(form.valid){
const _this = this;
this.postsService.savePost(form.value).subscribe(
{
next: (res)=>{
console.log(res);
},
error: (error)=>{
console.log(error);
},
complete: ()=>{
console.log("complete");
}
}
);
}else{
this._snackBar.open("You can not post empty article","", {
duration: 1000,
});
}
}
//service code
const headers = new HttpHeaders().set('Content-Type',
'application/json');
savePost(post:Object):Observable<HttpResponse<Post>> {
return this.http.post<Post>(this.URL +"/savePost",post, {
observe: "response",
headers:headers});
}
【问题讨论】:
-
请分享您的代码
标签: angular spring-boot api