I have this issue... I'm using ng-repeat with inner to obtain the data inside a child, this works perfectly but I cannot find the method to get the length of the ng-repeat. I need to get the count of the comments.
How to obtain the ng-repeat length using inner?:
js:
angular.module('myApp.Profile', ['ngRoute', 'firebase'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/Profile', {
templateUrl: 'Profile/Profile.html',
controller: 'ProfileCtrl'
});
}])
.controller('ProfileCtrl', ['$scope', '$firebase', '$firebaseArray', '$firebaseObject', function ($scope, $firebase, $firebaseArray, $firebaseObject) {
var firebaseRefs = firebase.database().ref('PostUsers/');
$scope.PostList = $firebaseArray(firebaseRefs);
}]);
html:
<body ng-controller="ProfileCtrl">
<div ng-repeat="PostList in PostList">
<p>Author: {{PostList.userAuthor}}</p>
<p>Comments: {{PostList.post}}</p>
<div ng-repeat="innerPostList in PostList.PostedComments">
<p>Author: {{innerPostList.username}}</p>
<p>Comments:{{innerPostList.comments}}</p>
</div>
</div>
<h4>Publications number: {{PostList.length}}</h4>
<h4>Comments number: {{????.length}}</h4>
</body>
I'm using Firebase:
NOTE:{{ PostList.PostedComments.length}} is not working...
this error appears when I try this in the controller: angular.js:13920 TypeError: Cannot read property 'length' of undefined. This is what I did:
var value = PostList.PostedComments.length;
console.log('the comments value is:' + value);
but when I try this it works fine:
var value = PostList.length;
console.log('the comments value is:' + value);
{{PostList.PostedComments.length}}
` ? – matmo Aug 17 '16 at 23:17