Skip to content

Instantly share code, notes, and snippets.

@wholypantalones
Created July 22, 2014 17:14
Show Gist options
  • Select an option

  • Save wholypantalones/cf71f7ee5d34a55fe649 to your computer and use it in GitHub Desktop.

Select an option

Save wholypantalones/cf71f7ee5d34a55fe649 to your computer and use it in GitHub Desktop.
Angular count objects
// usage {{countSeats(table.seats)}}
// fiddle http://jsfiddle.net/wholypantalones/vCMEM/1/
$scope.countSeats = function(seatsObj) {
if(typeof(seatsObj) !== "undefined") {
return Object.keys(seatsObj).length;
} // prevents "Error while interpolating"
}; // in dom
angular.forEach($scope.tables, function(val,key) {
console.log(Object.keys(val.seats).length);
}); // in scope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment