Reputation: 3340
I have a app built with Angular and Angular UI. I am trying to count the characters across multiple accordions, as displayed in the plunker. The code I have only returns the first two characters and then nothing?
Is there something wrong I am doing?
The plunk is: Example code
app.js
$scope.what=[];
$scope.why=[];
Object.defineProperty($scope, 'characters', {
get() {
return $scope.what.length + $scope.why.length;
}
});
HTML:
{{characters}}
But like I said this only returns the first two characters?
Upvotes: 0
Views: 102
Reputation: 5243
why and what are arrays, if you want to count all the characters in these arrays, try :
Object.defineProperty($scope, 'characters', {
get() {
return $scope.what.join('').length + $scope.why.join('').length;
}
});
Upvotes: 1
Reputation: 411
You could write up a function with a for loop to count the index of what
and why
and then place that in the AngularJS.
Upvotes: 0