【发布时间】:2015-11-12 10:29:41
【问题描述】:
这让我发疯了,我知道这一定是我想念的一些非常简单的事情!
我有一个返回 JSON 对象的服务:
[{"accountId":"0000004000006195","title":null,"firstName":"JOE","middleName":"BLOG","lastName":"BLOGGS","suffix":null,"primaryAddress":{"addressLine1":"TEST ADDRESS CLOSE","addressLine2":null,"addressLine3":"MY TOWN","town":"Washington","county":null,"country":"US","postcode":"PO9868"},"customerTelephones":[{"phoneNumber":"09876543455","type":"Alternate 1"},{"phoneNumber":"98654345676","type":"Alternate 2"}],"birthDate":108628400000}]
我正在尝试显示 JSON 的属性,例如名字使用:
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
$scope.testJson = [{"accountId":"0000004000006195","title":null,"firstName":"JOE","middleName":"BLOG","lastName":"BLOGGS","suffix":null,"primaryAddress":{"addressLine1":"TEST ADDRESS CLOSE","addressLine2":null,"addressLine3":"MY TOWN","town":"Washington","county":null,"country":"US","postcode":"PO9868"},"customerTelephones":[{"phoneNumber":"09876543455","type":"Alternate 1"},{"phoneNumber":"98654345676","type":"Alternate 2"}],"birthDate":108628400000}]
});
HTML:
<p>{{testJson}}</p>
<p>{{testJson.firstName}}</p>
但由于某种原因,{{testJson.firstName}} 显示为空白!
这是一个笨蛋:http://plnkr.co/edit/VWJfcXTPaDut2jqB4W3o?p=preview
有什么想法吗?
【问题讨论】:
标签: javascript json angularjs angularjs-scope