ngRepeat:dupes错误尝试在html上显示消息时

时间:2016-12-07 22:50:08

标签: javascript html json validation

我正在从REST API获得响应,我正在尝试使用HTML在屏幕上填充这些错误消息,这种情况很好。但只要有成功案例,我的Json变得多样化,当我尝试填充在HTML上我收到一个错误,如[ngRepeat:dupes]。我尝试添加trackby $ index。 [ngRepeat:dupes]消失但仍然没有打印在HTML上。这是我的HTML

   <div ng-show="errorui">
       <table>          
        <tr ng-repeat='(item, itemData) in dbresponse.errors'>
        <td align="left" class="validationMsg"><img src="images/red_bullet.gif" border="0" width="8" height="8" alt="">&nbsp;{{itemData.message}}</td></tr>
    </table> 
  </div>

<div ng-show="successui">
    <table>         
        <tr ng-repeat='list in successresponse'>
        <td align="left" class="validationMsg"><img src="images/red_bullet.gif" border="0" width="8" height="8" alt="">&nbsp;{{list}}</td></tr>
    </table> 
</div>

这是我的错误CASE的JSON输出(HTML中的errorui div)。这很好用

{
"success": false,
"timestamp": 1481126855178,
"errors": [{
    "message": "Please Enter Valid Format in Beginning Time"
}, {
    "message": "Please Enter Valid Format in Ending Time"
}, {
    "message": " Please Enter only one value in d/L/P box only "
}],
"StatusList":[]  }

这是我成功案例的JSON输出,现在当我尝试在屏幕上显示它时出现错误

    {
"success": true,
"timestamp": 1481150829322,
"message": "Configuration has been Added Successfully",
"eurexStatusList": []
}    

这是我的控制器部分

  $http.post('http://localhost:8080/services/add-config', dataobj)
       .then(function(response) {
      $scope.dbresponse = response.data;
      console.log($scope.dbresponse);
      if($scope.dbresponse.success != true){
           $scope.errorui = true;
      }else {
                  $scope.successresponse = $scope.dbresponse.message;
                  console.log($scope.successresponse);
                  $scope.successui = true;
              }

1 个答案:

答案 0 :(得分:0)

我找到了答案,消息是字符串值而不是对象列表。我尝试输出这样的消息并且它有效{{successresponse}}。谢谢所有人

相关问题