Angular JSからRestを呼び出しています。 APIからの応答を取得するとng-repeatを使用してフロントエンドでメッセージを作成する予定です。これはコントローラのサイドコールです。Angular JSでng-repeatを使用してREST APIから値を取り込むことができません
$http({
url: "http://localhost:8080/services/AddConfig",
method: "POST",
data: dataobj,
headers: {
'Content-Type': 'application/json'
}
}).success(function(data, status, headers, config){
responseData = data;
$scope.dbresponse = responseData;
console.log(responseData);
console.log($scope.dbresponse[0].messages);
console.log($scope.dbresponse[0].errors);
if($scope.dbresponse[0].messages[0] != null){
console.log("success message");
console.log("After Setting it");
}else if ($scope.dbresponse[0].errors != null){
console.log("has errors throw validation message");
}
}).error(function(error){
alert("Please Try again");
});
コンソール
Object
errors:null
messages:Array[1]
0:Added Successfully
私は何をしたい、そのメッセージにアクセスして行うにはNGリピートを使用して、フロントエンド.I'mに移入され、その失敗に見られるように、これは私のrepsonseです。
これは、あなたの 'dbresponse' の配列であると思われる私のHTMLあなたのAPI呼び出しの応答で
<table>
<tr ng-repeat="messages in dbresponse.messages">
<td align="left" class="validMsg"><img src="images/red_bullet.gif" border="0" width="8" height="8" alt=""> {{messages}}</td></tr>
</table>
Hey Filipe、それはタイプミスでした。私はこれだけのようにng-repeatを使用しようとしています
関連する問題