Skip to content

Commit

Permalink
Avoid undefined errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kaladay committed May 11, 2020
1 parent 302cacf commit 5bc6969
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/controllers/productController.js
Expand Up @@ -119,9 +119,13 @@ app.controller('ProductController', function ($controller, $scope, ApiResponseAc
};

$scope.getRemoteProductByRemoteProductInfo = function(remoteProductInfo) {
return $scope.remoteProducts[remoteProductInfo.remoteProductManager.id].filter(function(rp) {
return rp.id === remoteProductInfo.scopeId;
})[0];
if (angular.isDefined(remoteProductInfo.remoteProductManager.id)) {
if (angular.isDefined($scope.remoteProducts[remoteProductInfo.remoteProductManager.id])) {
return $scope.remoteProducts[remoteProductInfo.remoteProductManager.id].filter(function(rp) {
return rp.id === remoteProductInfo.scopeId;
})[0];
}
}
};

RemoteProductManagerRepo.listen([ApiResponseActions.CREATE, ApiResponseActions.DELETE, ApiResponseActions.UPDATE], function () {
Expand Down

0 comments on commit 5bc6969

Please sign in to comment.