在单独的行

时间:2018-01-10 15:03:05

标签: angular rest swagger

我有一个Angular2表单,其验证来自REST API服务器,其格式如下所示(在某些情况下会出现多个验证错误)

[
  "Management Date must be within six months",
  "Management Time Hour is Invalid. Please enter the hours only in between 1 
    to 12",
  "Management Time Mins is Invalid. Please enter the Mins only in between 00 
   to 59"
]

在.ts文件上,我正在访问以下消息 -

.subscribe(
  data => {
   if(condition = true){
    this.clear();
    this.success(data);
    }else{
    this.clear();
    this.error(data);
    }

HTML,有一个显示样式信息的div -

    <div class="col-md">
     <alert></alert>
     <router-outlet></router-outlet>
    </div>

现在,当我尝试显示来自API Response Body的验证消息时,它在HTML页面中显示如下 -

   ["Management Date must be within six months", "Management Time Hour is Invalid. Please enter the hours only in between 1 to 12", "Management Time Mins is Invalid. Please enter the Mins only in between 00 to 59"]

但我希望像这样实现它 -

    Management Date must be within six months
    Management Time Hour is Invalid. 
    Please enter the hours only in between 1 to 12
    Management Time Mins is Invalid. Please enter the Mins only in between 00 to 59

关于此的任何指示?非常感谢您的回应和见解。新手 - 服务器端 - 开发人员在短时间内学习TON,这么多小问题就出现了!

提前谢谢你。

更新:这是我用来在我的代码中实现警报消息的警报服务。 http://jasonwatmore.com/post/2017/06/25/angular-2-4-alert-toaster-notifications

0 个答案:

没有答案