Javascript 如何将Json与角js调用
我正在尝试修复我的响应函数 我认为问题在于我的controller.js,但我可能大错特错:Javascript 如何将Json与角js调用,javascript,jquery,json,angularjs,Javascript,Jquery,Json,Angularjs,我正在尝试修复我的响应函数 我认为问题在于我的controller.js,但我可能大错特错: angular .module('OrganisatieApp.controllers', []) .controller('organisatieController', function ($scope, organisatieAPIservice) { $scope.organisatieList = []; organisatieAPIservic
angular
.module('OrganisatieApp.controllers', [])
.controller('organisatieController', function ($scope, organisatieAPIservice) {
$scope.organisatieList = [];
organisatieAPIservice.getOrganisaties().success(function (response) {
//Assign response in Callback
$scope.organisatieList = response(); // as you can see here there needs something to be added but i really dont know what it could be.
});
});
$scope.organisatieList = response(what is in here?);
通常情况下,会是这样的:
response.MRData.StandingsTable.StandingsLists[0].DriverStandings;
但我不知道这方面发生了什么
这是我的app.js
这是my services.js:
这是我的html分区:
<div class="panel-body">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Organisatie naam</th>
<th>Organisatie plaats</th>
<th>Organisatie Curriculum</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="organisatie in organisatieList">
<td>{{$index + 1}}</td>
<td>
<img src="/img/logos/{{organisatie.Organisatie.logo}}.png" />
{{organisatie.Organisatie.orgNaam}} {{organisatie.Organisatie.orgVolledig}}
</td>
<td>{{organisatie.Constructors[0].provincie}}</td>
<td>{{organisatie.curriculum}}</td>
</tr>
</tbody>
</table>
</div>
我做错了什么?为什么我不能在我的表中获取数据?在services.js中,您正在注入ngResource,但您使用的是$http。似乎该url不支持jsonp,它返回json而不是带有填充的json,同样在使用jsonp时,您也需要。ngResource是问题所在。但现在我必须让它对json起作用,因为它会回馈json。这可能是一个愚蠢的问题,但是:我如何让它支持jsonp,或者如何让json为我工作。非常感谢!你有工作吗?你能详细说明一下吗
angular
.module('OrganisatieApp.services', ['ngResource'])
.factory('organisatieAPIservice', function ($resource) {
var organisatieAPIservice = [];
organisatieAPIservice.getOrganisaties = function () {
return $http({
method: 'JSONP',
url: 'http://jbossews-themaopdracht78.rhcloud.com/rest/json/org/Organisaties'
});
}
return organisatieAPIservice;
});
<div class="panel-body">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Organisatie naam</th>
<th>Organisatie plaats</th>
<th>Organisatie Curriculum</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="organisatie in organisatieList">
<td>{{$index + 1}}</td>
<td>
<img src="/img/logos/{{organisatie.Organisatie.logo}}.png" />
{{organisatie.Organisatie.orgNaam}} {{organisatie.Organisatie.orgVolledig}}
</td>
<td>{{organisatie.Constructors[0].provincie}}</td>
<td>{{organisatie.curriculum}}</td>
</tr>
</tbody>
</table>
</div>