0
我有麻烦将数据库信息返回到控制器。将数据返回给控制器的问题
我的控制器调用怪胎服务,与
$scope.dataValues = Geek.get();
然后服务的作用:
get : function() {
return $http.get('/api/geeks');
},
然后我的路线一样。
app.get('/api/geeks', function(req, res) {
// use mongoose to get all nerds in the database
Route.find({},function(err,docs) {
res.json(docs);
});
});
我很困惑时,当调用回来给控制器,有什么也没有和页面的样子。 http://prntscr.com/3g0whh。
如果我在路由中放置了一个console.info(docs),它会打印出来。
然而,它似乎并没有要回控制器,这使得dataValues = {}
[ { _id: '53639917f4ae962320d1711a',
MailItem:
{ objectId: 'ObjectRef',
volume: '100',
weight: '5',
priority: 'InternationalAir',
route: '',
dateEntered: 'Thursday',
timeEntered: '20/05/1415:35',
price: '7.50',
dimension: { height: '4', width: '4', length: '4' } } } ]
Geek.html
<ul>
<li ng-repeat="mailItem in dataValues">
{{mailItem.price}}
</li>
</ul>
{{dataValues}}
嘿,这是有道理的。谢谢 ! – user2469515