Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 显示成功消息_Node.js_Angular_Html_Express - Fatal编程技术网

Node.js 显示成功消息

Node.js 显示成功消息,node.js,angular,html,express,Node.js,Angular,Html,Express,我有一个表单,我想在用户单击提交后显示一条成功消息 这是我的 <form [formGroup]="angForm" novalidate> <div class="form-group"> <label class="col-md-4">Comment author</label> <input type="text" class="form-control"

我有一个表单,我想在用户单击提交后显示一条成功消息

这是我的

 <form [formGroup]="angForm" novalidate>
            <div class="form-group">
              <label class="col-md-4">Comment author</label>
              <input type="text" class="form-control" name="author" formControlName="author" #author />
            </div>
            <div *ngIf="angForm.controls['author'].invalid && (angForm.controls['author'].dirty || angForm.controls['author'].touched)"
              class="alert alert-danger">
              <div *ngIf="angForm.controls['author'].errors.required">
                Name is required.
              </div>
            </div>
            <div class="form-group">
              <label class="col-md-4">comment description</label>
              <input type="text" class="form-control" formControlName="description" #description/>
            </div>
            <div *ngIf="angForm.controls['description'].invalid && (angForm.controls['description'].dirty || angForm.controls['description'].touched)"
              class="alert alert-danger">
              <div *ngIf="angForm.controls['description'].errors.required">
                description is required.
              </div>
            </div>
            <div class="form-group">
              <button (click)="addReview(author.value, description.value)" [disabled]="angForm.pristine || angForm.invalid" class="btn btn-primary">Add</button>
            </div>
          </form>

当用户单击“提交”按钮时,一切正常,数据被提交并保存到数据库,但不会显示flash消息,例如,您的评论已成功添加“我需要更改什么才能显示成功消息?”根据您的代码,我猜您错过了在html中显示flash消息的容器。 将此添加到html中,无论您想在何处显示flash消息

    <flash-messages></flash-messages>

您是否在浏览器窗口的控制台中看到任何错误

确保必须在app.module.ts文件中添加
FlashMessagesModule

import { FlashMessagesModule } from 'angular2-flash-messages';

@NgModule({
    imports: [        
        FlashMessagesModule.forRoot(),
    ]
})
在应用程序组件文件中添加此标记

<flash-messages></flash-messages>

有关更多详细信息,请访问官方网站。


我希望这会有所帮助。

您可以添加引导警报,以向用户显示反馈消息。@BradmCalister hii您能给我举个例子吗?我是新来的stuff@bradmcallister我需要在哪里添加该警报?可以在此处找到警报文档:。您可能希望将警报设置为显示在FlashMessages服务的位置。我知道这是我的问题。如果我不知道如何正确地实现它,你可以看到:(你能提供一些类似的例子吗?我有一个应用程序内组件:)
addReview(author,description){this.moviesService.addReview(author,description);this.\u flashMessagesService.show('你的评论已成功添加');}这里有点不对劲
在html中也有点不对劲,你能举个有效的例子吗@耶
<flash-messages></flash-messages>