【发布时间】:2017-04-15 03:38:15
【问题描述】:
我正在从 angular 到 Spring 进行 REST 调用。我能够得到响应。当我尝试使用 ng-repeat 填充视图中的值时,屏幕上没有显示任何内容。
这是我的 Angular 代码 此代码在 showhidecontroller 中
var resuls = $http.post('http://localhost:8080/aeservices/AddConfig', dataobj);
resuls.success(function(data, status, headers, config) {
$scope.dbresponse= data;
$scope.messagetest = $scope.dbresponse[0].messages;
alert($scope.messagetest);
console.log( $scope.messagetest);
console.log(data);
});
这是我从 API 收到的回复
[{
"data12": null,
"name": null,
"errors": ["error data1", "error data2"],
"messages": ["Configuration has been Added successfully", "Configuration has been Added successfully"]
}]
这是我的 HTML
<table ng-controller="ShowHideController">
<tr ng-repeat="item in dbresponse[0].errors" >
<span><td align="left" class="validationMsg"><img src="images/red_bullet.gif" border="0" width="8" height="8" alt=""> 
{{item}}
</td></span></tr>
</table>
我尝试使用 ng-repeat,将自己声明为 $scope.items = ['one','two','three','four'] 这样的项目。即使这也没有显示在 HTML 上。
【问题讨论】:
标签: angularjs html spring-mvc model-view-controller