Saturday, 22 April 2017

cannot access the .id value of a resource

Trying to access $scope.mySlot.id but it is undefined.

$scope.removeMe = function(){
    UserService.me().then(function(me){
    $scope.ME = me;
    });
    var userToRemove = $scope.ME;                                       
    var shouldRemove = confirm('Remove you from this field trip?');
    if (shouldRemove) {

        var data = {
            userID: userToRemove.id,
            eventID: tripID,
        }
        console.log("data: " );
        console.log(data);
        $scope.mySlot = GreenTripFilledSlotsFactory.get(data);   
        console.log('this is $scope.mySlot: ')
        console.log($scope.mySlot);
        console.log('this is $scope.mySlot.id : ')
        console.log($scope.mySlot.id);
         console.log('this is $scope.mySlot.userID : ')

        console.log($scope.mySlot.userID)

        $scope.mySlot.$delete(function(success){
            $route.reload();
        })  

    }
}

In the console.logs $scope.mySlot is shown as a resource and it does list the values of it. But I'm confused why $scope.mySlot.id is undefined.

Here is the console:

screenshot of console



via lightcollector7

No comments:

Post a Comment