ajax가있는 Angular Js를 사용하고 있지만 ng-repeat를 사용하면 json 배열에서 출력을 가져올 수 없습니다. 알리미 [Object object]를받는 중 ... $scope.names= response[0].id;
을 사용하여 경고시 "1"ID가 표시됩니다. 테이블의 모든 데이터를 가져와야합니다. 테이블에있는 모든 데이터를 가져올 수있는 방법이 있습니까? 또한 모바일 브라우저에서 작동하지 않지만 데스크톱에서 작동하기 때문에 컨트롤러에 $http
을 사용하고 있지 않습니다. 왜 그런지 모르십니까? 제발 도와주세요! 대신 AJA의Angular Js ng-repeat가 json 배열에서 ajax를 사용하여 출력되지 않습니다.
JS
var app = angular.module('studentApp',[]);
app.controller('StudentCntrl', function($scope){
$.ajax({
url : '/fetchAllData',
type : 'GET',
success : function(response){
$scope.names=response;
//alert($scope.names);(This is working)
}
});
});
JSP
<div ng-app="studentApp" ng-controller="StudentCntrl">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>NAME</th>
<th>EMAIL</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="x in names">
<td>{{x.id}}</td>
<td>{{x.name}}</td>
<td>{{x.email}}</td>
</tr>
</tbody>
</table>
</div>
JSON
[{"id":"1","name":"abdul","email":"[email protected]"},{"id":"2","name":"pratyush","email":"[email protected]"},{"id":"3","name":"ankit","email":"[email protected]"},{"id":"45","name":"kjhj","email":"kjhkj"},{"id":null,"name":null,"email":null},{"id":null,"name":null,"email":null},{"id":null,"name":null,"email":null},{"id":"trffs","name":null,"email":null},{"id":"afa","name":"sdgfdsg","email":"dsagdsg"},{"id":"12","name":"pppp","email":"hjk,gh"}]
'$ http'를 삽입하지 마십시오. – scniro
모바일 브라우저에서는 처음 시도했지만 작동하지 않습니다. –
어떤 각도 버전과 브라우저 유형 및 버전입니까? 다른 사람들이 언급했듯이 $ http가 올바르게 사용되면 모바일에서도 작동해야합니다. 너 – codemax