Mikyas TADESSE Mikyas TADESSE - 1 year ago 81
AngularJS Question

How to access data in a promise angularjs

I wanted to access a data in promise. I have the following code :

function getUser() {
Users.query({username: usersOnline}).$promise.then(function (results) {
$scope.userss = results;
return results;
}, function(error) {
// console.log(error);
//$scope.meetups = [];

But i get an error saying cant find property then of undefined can you help

Answer Source

Return Users.query promise from getUser user function, as caller function is performing .then(expecting promise) there.

function getUser() {
//return promise here
    return Users.query({username: usersOnline}).$promise
    //other code as is

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download