Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checkAll Not Working when Array is 'ID' Only ($scope.roles.map Functionality) #162

Open
tramel-woodard opened this issue Aug 7, 2017 · 0 comments

Comments

@tramel-woodard
Copy link

tramel-woodard commented Aug 7, 2017

Actually, the poster of #49 had the same question, but the issue was closed without solving the original poster's issue of using the $scope.object.map functionality.

This is for the example where each object in the array has both an "id" and "text" field:

$scope.roles = [
{ id: 1, text: 'guest' },
{ id: 2, text: 'user', },
{ id: 3, text: 'customer' },
{ id: 4, text: 'admin' }
];

The original poster must use the $scope.object.map function in order to just return the id only (or whichever array you're using for your data source:

$scope.checkAll = function() {
$scope.user.roles = $scope.roles.map(function(item) { return item.id; });
};

The error I'm receiving when clicking my "Check All" button for "id only" check all is the following:

TypeError: Cannot read property 'map' of undefined'
at Scope.$scope.checkAll (file.js xx:xx)

I'm especially facing this issue when the "id" primary key of my object isn't simply id, but instead something like bookId.

Haven't been able to find the underlying issue for the last few days, wondering if someone is using the $scope.object.map function and facing a similar issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant