Mayank Bhushan

Mayank Bhushan

  • NA
  • 40
  • 3.3k

Regarding get index value

Jun 4 2018 8:28 AM
<div angucomplete-alt id="ex5" placeholder="Search By Food Items" pause="100"
selected-object="SelectedItems" ng-model="items.itemSelected" local-data="arrItems" search-fields="ItemsName"
title-field="ItemsName" minlength="1" input-class="form-control" match-class="highlight" ng-required="true" input-changed="inputChanged" auto-match="true" ng-value="{{$index}}" ng-click="getMonthId($index)">
<input id='x' type='hidden' name='token' ng-model='items.token' value='{{$index++}}' />
</div>
 
 
 
How to get index value in ---
 
$scope.SelectedItems = function (selected) {
ItemsId = selected.originalObject.ItemsId;
Name = selected.title;
//alert(items.itemSelected)
console.log('txtAutocomplete', index);
$http({
method: 'POST',
headers: { 'Content-Type': 'application/json' },
data: '{ "ItemsId":"' + ItemsId + '" ,"ItemsName":"' + Name + '" }',
}).then(function (response) {
var resTotal = JSON.parse(response.data);
console.log('resTotal', resTotal);
var i = 0
//for (i == 0; i <= resTotal.length; i++) {
$scope.tempValue = resTotal[0].TotalCalories;
//console.log('$scope.items.txtitemCal[Index]', $scope.items.txtitemCal[Index])
//$scope.price[]
$scope.items.txtitemCal = $scope.tempValue * $scope.items.txtitemsCount;
// arrtoatlAmount.push($scope.txtitemCal);
// }
// $scope.price[index] = resTotal[0].TotalCalories;
console.log('$scope.txtitemCal', $scope.tempValue);
}, function (response) { // optional
// failed
console.log('failed');
console.log(JSON.stringify(response));
});
}
 
Please reply me asap. 

Answers (2)