mercredi 5 octobre 2016

Why am I getting this Type Error - push is not a function?

I have this $http.get and am trying to push the result to an array but continue you to get a Type Error that $items.push is not a function.

The result is an object. I have tried to declare it as an array and use toArray() in my controller to serialize it but nothing seems to resolve.

$scope.items = [];
$scope.item = [];
$scope.itemNumber = '';

$scope.addItem = function (){
    $http.get('../item/' + this.itemNumber).success(function (result) {
        $scope.item = result;
        $scope.items.push({"item_number":$scope.item.item_number, "oemnumber":$scope.item.oemnumber});
    })
};

What am I missing?? Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire