Javascript 获取Json值
您好,我在使用Angular JS调用Json数组的值时遇到问题 以下是JSON数组(已更新): 这是我用来显示数据的HTML页面。(更新)Javascript 获取Json值,javascript,json,angularjs,Javascript,Json,Angularjs,您好,我在使用Angular JS调用Json数组的值时遇到问题 以下是JSON数组(已更新): 这是我用来显示数据的HTML页面。(更新) 开孔粪 开孔霍拉 克拉西菲卡翁 诊断学 再结晶 因苏莫斯 费查·德西尔酒店 霍拉·德·西尔 普里奥里达 不可分解的 阿费克塔多斯系统 {{偶然的,偶然的} {{偶然的,偶然的} {{偶然的,偶然的} {{偶然的诊断} {{incident.resolucion} {{incident.insumos}} {{incident.cierre
开孔粪
开孔霍拉
克拉西菲卡翁
诊断学
再结晶
因苏莫斯
费查·德西尔酒店
霍拉·德·西尔
普里奥里达
不可分解的
阿费克塔多斯系统
{{偶然的,偶然的}
{{偶然的,偶然的}
{{偶然的,偶然的}
{{偶然的诊断}
{{incident.resolucion}
{{incident.insumos}}
{{incident.cierrefecha}}
{{意外事件,cierrehora}
{{偶然的,优先的}
{{偶然的不可抗力}
{{incident['sistemas'][0].sistema.nombre}
根据这一点,它应该反映价值观,但事实并非如此。我尝试了我所能想到的每一次抽搐
这是角度文件:
.controller('IncidenteController', [ '$scope', '$http', function($scope, $http) {
var urlbase = "http://localhost:8080/get/";
var onError = function(reason) {
$scope.error = "No se pudo encontrar";
};
var onIncidenteComplete = function(response) {
$scope.incidentes = response.data;
$scope.sistema = incidente.sistema; <--- this is useless
};
$http.get(urlbase + "incidente/").then(onIncidenteComplete, onError);
$scope.obtenerSistemas = function(incidente) {
$scope.sistema = incidente.sistema;
};
.controller('IncidenceController',['$scope','$http',函数($scope,$http){
var urlbase=”http://localhost:8080/get/";
var onError=功能(原因){
$scope.error=“无se pudo encontrar”;
};
变量onIncidenteComplete=函数(响应){
$scope.incidents=response.data;
$scope.sistema=incident.sistema;您是否尝试使用angular.fromJson(数据)
我有这个:
var parsedDashboard = angular.fromJson(data);
console.log(parsedDashboard);
数据来自json数据的HTML响应
上述内容适用于第1.4.6节
在您的情况下,应该是:
$scope.incidentes = angular.fromJson(your json data here)
另外,尝试将ng repeat放在tr上,而不是放在其自身上:
<table st-table="displayedCollection" st-safe-src="customers" class="table table-striped" id='customers'>
<thead>
<tr>
<th st-sort="id">ID</th>
<th st-sort="name">Name</th>
<th st-sort="total">Total Ordered in {{searchObject.Duration}}</th>
</tr>
</thead>
<tbody>
<tr st-select-row="row" ng-repeat="x in displayedCollection" ng-click="setSelected(this)" class="{{selected}}">
<td>{{ x.id }}</td>
<td>{{ x.name }} </td>
<td>{{ x.total | currency : '$' : 2 }} </td>
</tr>
</tboday>
<tfoot>
<tr>
<td colspan="5" class="text-center">
<div st-pagination="" st-items-by-page="itemsByPage" st-displayed-pages="displayedPages"></div>
</td>
</tr>
</table>
身份证件
名称
在{{searchObject.Duration}中排序的总数
{{x.id}
{{x.name}
{{x.total}货币:'$':2}
如果您的数据是以数组形式提供的,这就足够了:
var onIncidenteComplete = function(response) {
$scope.incidentes = response.data[0].incidentes;
};
演示:
编辑:
嵌套咨询的plnkr演示。您是否检查了响应。数据
以确保它是您认为的?显示了什么?为什么您的ng repeat
在
上?它通常在
上。它没有任何区别,我通常将ng repeat放在TR中。我切换了它,尝试一些事情,因为似乎什么都不起作用,我不确定我调用的angular.controller是否错误,或者我是否应该修复我的angular.controller。如果你使用“Console.log($scope.incidences)”,你在那里看到你的json值了吗?我通常使用get和post数据执行普通http请求。如果你使用Console.log(response)并查看它从那里得到了什么?数组[Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,Object,1更多…]incident.js:63:6是否应从数组中取出json数据?如果设置$scope.incidents=$scope.incident[0]然后你只需要拥有所有的json数据。这可能是导致它的原因。根据angular文档:。我还将确保每个对象都有一个正确的(键、值)对。像符咒一样工作。+1
$scope.incidentes = angular.fromJson(your json data here)
<table st-table="displayedCollection" st-safe-src="customers" class="table table-striped" id='customers'>
<thead>
<tr>
<th st-sort="id">ID</th>
<th st-sort="name">Name</th>
<th st-sort="total">Total Ordered in {{searchObject.Duration}}</th>
</tr>
</thead>
<tbody>
<tr st-select-row="row" ng-repeat="x in displayedCollection" ng-click="setSelected(this)" class="{{selected}}">
<td>{{ x.id }}</td>
<td>{{ x.name }} </td>
<td>{{ x.total | currency : '$' : 2 }} </td>
</tr>
</tboday>
<tfoot>
<tr>
<td colspan="5" class="text-center">
<div st-pagination="" st-items-by-page="itemsByPage" st-displayed-pages="displayedPages"></div>
</td>
</tr>
</table>
var onIncidenteComplete = function(response) {
$scope.incidentes = response.data[0].incidentes;
};