I build chat application, that can display all friends in friend list using ng-repeat. this is the code:
<div class="scrollable">
<div class="scrollable-content">
<div class="list-group">
<div class="list-group-item">
<h5>Welcome <b>{{ datauser['data']['nama'] }}</b></h5>
<input type="search" class="form-control app-search" placeholder="Search.." data-ng-model="search" />
<div class="list-group-item media" href="#" ng-repeat="friend in datauser['data']['friends'] | filter : {nama : search}" data-ng-click="chatWith(friend.userid , friend.nama)" data-ng-class="(friend['ischat'] ? 'blokchat' :'')">
<div class="pull-left">
<i class="fa fa-user chat-user-avatar"></i>
</div>
<div class="media-body" >
<h5 class="media-heading">{{friend.nama}} <span class="badge bg-danger" data-ng-if="friend['ischat']">*</span></h5>
</div>
</div>
</div>
</div>
</div>
ng-repeat="friend in datauser['data']['friends'] | filter : {nama : search}"
is to display all friend, the newer friend will be at bottom of this index. this index will always add up when user have new friend. every users have different total friends, so the length of index is not exact its depends on how many friends that user have. my question is, how do I get the value from length of this index? because this value will be used in my speech recognition like this:
$scope.recog = function() {
var recognition = new SpeechRecognition();
recognition.onresult = function(event) {
var msg = 'Sorry, there is no such a command like that';
var result = event.results[0][0].transcript;
switch(result){
case 'chat with friend number [i]':
$scope.chatWith(friend.userid , friend.nama);
break;
default:
navigator.notification.alert(msg, '', 'Undefined Command!','ok');
break;
};
$scope.$apply()
};
recognition.start();
};
so, I will use 'chat with friend number [i]' as command, 'i' in here is the total length of the index in ng-repeat, 'i' is from 0 until length-1. How do I make this?