【发布时间】:2015-07-29 08:51:47
【问题描述】:
我正在尝试使用此代码绑定数据:
{{company.category}} | {{company.locations[0]}}
{{company.company_name}}
输出是:
[{"id":1,"category":"Advertising and Agencies"},{"id":2,"category":"Arts and Music"},{"id":3,"category":"Client Services"},{"id":4,"category":"Consumer"},{"id":5,"category":"Education"}] | {"id":1,"cities":"Delhi"}
Microsft Corp
我不知道为什么会有这么多大括号和 id。我哪里错了?我正确显示了 company_name。
【问题讨论】:
-
查看您提供的信息,我会说您的模型在
company.category中包含一个列表,这就是正在显示的内容。 -
这是从网络捕获的:> category: [{id: 1, category: "Advertising and Agencies"}, {id: 2, category: "Arts and Music"},...] 0 : {id: 1, category: "广告和代理机构"} 1: {id: 2, category: "艺术和音乐"} 2: {id: 3, category: "客户服务"}
-
你正在打印整个数组和它显示的对象,其中你的名字是一个单一的 arribute,所以它显示正确..问题在于你的表示
标签: angularjs angularjs-ng-repeat angularjs-bindings