Javascript 如何使用angularjs查找嵌套json对象?
如何找到嵌套的JSON对象并使用AngularJS输出?我已经搞砸了很长一段时间了,但我似乎就是搞不好。。希望你们能帮助我 HTML: Ctrl: 而不是Javascript 如何使用angularjs查找嵌套json对象?,javascript,json,angularjs,Javascript,Json,Angularjs,如何找到嵌套的JSON对象并使用AngularJS输出?我已经搞砸了很长一段时间了,但我似乎就是搞不好。。希望你们能帮助我 HTML: Ctrl: 而不是 <div ng-repeat="post in posts"> 使用post in YourVar.data.posts来代替post in postsShow AnalyticsCtrl controller感谢您的信息!是否有任何方法可以将计数器与activeVisitors在同一个ng repeat中相乘(或进行任何数学
<div ng-repeat="post in posts">
使用
post in YourVar.data.posts来代替post in posts
Show AnalyticsCtrl controller感谢您的信息!是否有任何方法可以将计数器与activeVisitors在同一个ng repeat中相乘(或进行任何数学运算)?
{
"status" : "success",
"data" :
{
"activeVisitors" : "148",
"posts" :
[
{
"id" : 1,
"title" : "Bla blabla blablabl bla blablaba",
"counter" : "20"
},
{
"id" : 2,
"title" : "Blie bla blup wflup flel del",
"counter" : "18"
},
{
"id" : 3,
"title" : "Flel djep flep tro fro klel",
"counter" : "14"
}
]
}
}
'use strict';
var myApp = angular.module('myApp', []);
myApp.controller('AnalyticsCtrl', ['$scope', '$http', function($scope,$http) {
$http({method:'POST', url: 'jsonData.php', headers: {}})
.success(function(data) {
$scope.posts = data;
});
}]);
<div ng-repeat="post in posts">
<div ng-repeat="post in posts.data.posts">
$http({method:'POST', url: 'jsonData.php', headers: {}})
.success(function(data) {
$scope.posts = data.data.posts;
});