1

I want to add new row in table.Where table data is coming from database.which is as follow..

<div class="form-group form-horizontal" id="item" style="margin: 5px;">
    <label class="col-xs-2 control-label">Enter Barcode:</label>
    <div class="col-xs-2 selectContainer">
        <input type="text" class="form-control" ng-model="barcode" placeholder="enter barcode" />
    </div>
    <label class="col-xs-1 control-label">Quantity</label>
    <div class="col-xs-2 selectContainer">
        <input type="text" class="form-control" ng-model="qnt" ng-blur="putQnt()" placeholder="enter quantity" />
    </div>
    <button class="col-xs-1 btn btn-primary" ng-click="getInfo()">OK</button>
    <button class="btn btn-primary" ng-click="addItem()">Add Item</button>
</div>

Here I've to add barcode and quantity from barcode the select query would be fired and I get the data in one row. It's angularjs,

$scope.getInfo=function(){
        $http.get("../POS_System/widget/bill.php?barcode="+$scope.barcode).success(function(data){
           $scope.data=data;  
        }); 
      $scope.list={};
    }

Now when I'm adding new row it's overwrite the data.I didn't get the combine data.so what to do for adding new row from database according to it's barcode entry.Give me some suggestion for addItem() function.

2
  • please add addItem function Commented Sep 13, 2016 at 12:08
  • please read a question I'm asking for that function.What would be that function? Commented Sep 13, 2016 at 12:14

1 Answer 1

1

You can do like this:

$http.get("../POS_System/widget/bill.php?barcode="+$scope.barcode).success(function(data){
    var tempvar = data;
    var len = (tempvar.length);
    if(len>0) {
         for(var loop=0;loop<len;loop++) {
             $scope.data.push(tempvar[loop]);
    }  
        }); 
Sign up to request clarification or add additional context in comments.

2 Comments

for what response.data is used?because I'm getting error for this.@Suresh Kamrushi
@KrishPatel: updated answer matching to your variables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.