我查询数据库和检索所有属于图像登录的用户,这里是uploadController代码:
UserImage.get($scope.user_id)
.success(function(data) {
$scope.userArray = data;
$location.path('/display');
});
我可以控制台日志数据的价值它是(头文件):
0: Object
__v: 0
_id: "563bd07c7a49a7ac9ae1c513"
date: "2015-11-05T21:56:12.312Z"
gallery: "first gallery"
name: "1b0f6d56-9ed6-4412-a0d6-897a25fb3a84-460x360.jpeg"
user: "563bd0527a49a7ac9ae1c512"
所以现在我测试的目标视图(display.html)可以收到$ scope.data:
<<div>{{userArray[0].name}}</div>
$ scope.userArray不适用于display.html。 我测试了$在掠夺者的范围,它的工作正常: http://plnkr.co/edit/q5XXnfl3JxkRdG0jLyps?p=preview 所以我有点难住。
什么是错误? – Sajeetharan
你还没有包含你的路由,但它看起来你添加了数据到你的范围,然后改变路径,我假设一个新的路线与不同的范围? – Tristan
@Tristan - 实际上是同一个控制器 - 没有改变。我尝试交换它,以便在$ scope给出数据之前更改路径,但没有区别。 – meanstacky