【发布时间】:2015-06-01 10:10:33
【问题描述】:
我有我的简单 HTML 文件和 JSON 文件
<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div ng-controller="aboutController">
<p ng-repeat="post in about">
{{name.about}}
</p>
</div>
<script src="angular.js"></script>
<script>
var myApp = angular.module('myApp', []);
myApp.controller('aboutController', function($scope, $http) {
$http.get('about.json').success(function(data, status, headers, config) {
$scope.about = data;
console.log('this is data:',data);
});
});
</script>
</body>
</html>
{
"name" : "Peter",
"surname" : "Chpoksky"
}
我需要从 json 文件传输数据,但由于某种原因,浏览器没有显示任何内容 有什么问题?
【问题讨论】:
-
你想准确显示什么?
-
@myros.092,
{{name.about}}应该是{{about.name}}。另外,console.log显示什么?
标签: javascript html json angularjs angularjs-directive