如您所知,可以按如下方式初始化对象:
<div ng-init="friends = [{name:'John', phone:'555-1276'},
{name:'Mary', phone:'800-BIG-MARY'},
{name:'Mike', phone:'555-4321'},
{name:'Adam', phone:'555-5678'},
{name:'Julie', phone:'555-8765'},
{name:'Juliette', phone:'555-5678'}]"></div>
是否可以通过函数定义类似的对象:
<div ng-init="init()">
我的目标实际上是从 API 中获取对象并通过 ng-repeat 在列表中显示它们