【发布时间】:2016-01-02 10:14:45
【问题描述】:
假设我有以下路线:
{
route: "usersById['length']",
get: function(pathSet) {}
},
{
route: "usersById[{integers:ids}]['firstName', 'lastName']",
get: function(pathSet) {}
}
在我的 angular1 控制器中使用以下内容:
Model.get(
'usersById.length',
'usersById[0..2]['firstName', 'lastName']'
).then(function(response) {
$scope.$apply(function() {
vm.entities = response.json.usersById;
});
});
来自服务器的响应将类似于:
{
jsonGraph: {
usersById: {
"0": {
firstName: 'Jiminy',
lastName: 'Cricket'
},
"1": {
firstName: 'Jafar',
lastName: 'Husain'
},
"length": 123123
}
}
}
在我的 angular 1 模板中,我想遍历用户列表:
<tr ng-repeat="entity in users.entities">
<td>{{entity.firstName}} {{entity.lastName}}</td>
</tr>
问题在于响应中不仅有用户,首先它包含length,其次似乎模型的承诺返回了其他元数据,其中看起来是路径数据的一部分:usersById
循环浏览用户列表的首选方式是什么?我应该在我的承诺中做这样的事情吗?
vm.entities = response.json.usersById.filter(function(value) {
return typeof value === 'object';
});
我没有看到任何用于在任何地方获取原始值的 API 调用。
【问题讨论】:
标签: angularjs falcor falcor-router