Created
July 22, 2014 17:14
-
-
Save wholypantalones/cf71f7ee5d34a55fe649 to your computer and use it in GitHub Desktop.
Angular count objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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