我想解析一个JSON文件,我为我正在创建的应用程序创建。 JSON文件看起来是这样的:用AngularJS解析JSON文件
{"thresholds":[
{"heatIndex":[
{"maxTemp":[{"red":"125","orange":"105","yellow":"90","green":"-80"}]},
{"minTemp":[{"red":"-50","orange":"-35","yellow":"-20","green":"0"}]}
]},
{"wind":[
{"speed":[{"red":"34.8","orange":"26.1","yellow":"17.4","green":"0"}]},
{"gust":[{"red":"50.4","orange":"39.1","yellow":"26.1","green":"0"}]}
]}
]}
我需要让我的角度应用输出的数据对我和一直在试图遵循http.get教程,我不能让我的数据出来。基本的一部分,我需要怎么我的角度应用程序的该部分格式的帮助:在您的$ HTTP请求
<ul>
<li ng-repeat="x in thresholds">
{{x.thresholds}}
</li>
</ul>
</div>
<!-- NG APP Script -->
<script>
var ehwo2App = angular.module('ehwo2App' , []);
ehwo2App.controller('ehwo2Ctrl' , function ($scope, $http) {
$http.get('config.json').success(function(data) {
$scope.thresholds = data;
});
});
</script>
$ scope.thresholds = JSON.parse(data); (因为数据是即将到来的字符串我想)问你的朋友谷歌之前发布问题http://stackoverflow.com/questions/4935632/parse-json-in-javascript –
@DmitriAlgazin实际上你不必这样做,角度自动为你解析json。除非你知道你是对的,否则试着在评论时不要低估。 –