the autocomplete textbox doesn't work when it is put inside ng-repeat of a table.
It is actually a bug.
How to solve it?
var poDetails = {};
$scope.itmDetails = {};
$scope.poId = null;
$scope.save = function () {
poDetails = {
"PURCHASEORDERNO": $scope.poNo,
"SUPPLIERID": $scope.selectSupplier.originalObject.SUPPLIERID,
"CREATEDDATE": $scope.currentdate,
"SUBTOTAL": $scope.subTotal,
"GRANDTOTAL": $scope.total
};
$http({
method: "POST",
url: "http://localhost:49556/api/purchaseOrder/addPoDetails",
data: JSON.stringify(poDetails),
dataType: 'json',
contentType: 'application/json'
}).then(function (data, status) {
//alert('SUCCESS');
$scope.poId = JSON.parse(data.data);
//alert($scope.poId);
debugger;
var a = $scope.itmDetails.length;
for (var i = 0; i < a; i++) {
debugger;
$scope.itmDetails = {
"POID": $scope.poId,
"ITEMID": $scope.selectItem.originalObject.ITEMID,
"UNITAMOUNT": $scope.itemDetail[i].rate,
"REQUIREDQTY": $scope.itemDetail[i].qty,
"TOTALAMOUNT": $scope.itemDetail[i].amt
};
alert($scope.itmDetails);
$http({
method: "POST",
url: "http://localhost:49556/api/purchaseOrder/addItemDetails",
data: JSON.stringify($scope.itmDetails),
dataType: 'json',
contentType: 'application/json'
}).then(function (data, status) {
alert('SUCCESS');
});
}
});
}
It is not getting inserted into the database, getting an error like this in the below mentioned line of code :
TypeError: Cannot read property 'originalObject' of null
"ITEMID": $scope.selectItem.originalObject.ITEMID,
<tr ng-repeat="itemDetail in itemDetails">
<td>
{{$index + 1}}
</td>
<td style="text-align: left">
<angucomplete-alt id="txtinvnumber" placeholder="Search Item Name" pause="100" selected-object="selectItem"
remote-url="http://localhost:49556/api/purchaseOrder/getPoItem" remote-url-data-field=""
local-data="item" search-fields="ITEMNAME" title-field="ITEMNAME" minlength="1"
input-class="form-control mr-sm-2" match-class="highlight" ng-click="Search()"></angucomplete-alt>
<input type="button" value="+" ng-click="addNewRow()" />
<input type="button" value="-" ng-click="removeRow($index)" />
</td>
<td>
<input type="text" ng-model="itemDetail.qty" ng-change="calc($index)" style="width: 40px;
text-align: right">
</td>
<td>
<input type="text" ng-model="itemDetail.rate" ng-change="calc($index)" style="width: 60px;
text-align: right">
</td>
<td>
<input type="text" ng-model="itemDetail.amt" value="{{amount}}" style="width: 60px;
text-align: right" readonly>
</td>
</tr>