I encountered an issue while attempting to set the database value using Angular.js.
Error:
TypeError: index.push is not a function
Below, I have provided an explanation of my code.
<tr ng-repeat="d in days">
<td>{{d.day}}</td>
<td> <select class="form-control" id="catagory" ng-model="catagory" ng-options="cat.name for cat in listOfCatagory track by cat.value " ng-change="removeBorder('catagory',$index,catagory.value);" >
</select></td>
<td>
<select class="form-control" id="subcatagory+$index" ng-model="subcatagory[$index]" ng-options="sub.name for sub in listOfSubCatagory+$index track by sub.value " >
<option value="">Select Subcategory</option>
</select>
</td>
<td><input type="text" name="comment" id="comment" class="form-control oditek-form" placeholder="Add Comment" ng-model="comment" ng-keypress="clearField('comment');"></td>
</tr>
When the user selects a value from the first drop-down list, the following part of the code executes.
$scope.removeBorder=function(id,index,catvalue){
var catdata=$.param({'action':'subcat','cat_id':catvalue});
$http({
method:'POST',
url:"php/customerInfo.php",
data:catdata,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).then(function successCallback(response){
//console.log('sub',response.data);
angular.forEach(response.data,function(obj){
var data={'name':obj.subcat_name,'value':obj.subcat_id};
$scope.listOfSubCatagory+index.push(data);
})
},function errorCallback(response) {
})
}
I am encountering an error with this line of code:
$scope.listOfSubCatagory+index.push(data);
. Any assistance in resolving this error would be greatly appreciated.