Home » Php » How to post Dynamic input field using angularjs in codeigniter

How to post Dynamic input field using angularjs in codeigniter

Posted by: admin June 30, 2018 Leave a comment


Here is My problem Below. Dynamics fields come from the database. But I am unable to post my field in angularjs. I want to post multiple records at a time but, it is still not posted. How to solve this problem. Because while posting multiple records with respect to multiple products, but it is not posted. if you have any solutions and suggestion please help me to come out this problem.

Html View:-

  <form method="POST" role="form" name="bill" ng-submit="makeBilling()">
     <div class="card-box">
                <div style="border-bottom: 2px solid #ebeff2;margin: 0;" class="row">
                    <div class="col-md-6" style="padding-left: 0;"><p style="font-weight: bold; color: #666666; padding: 8px; margin-bottom:0;">Items</p></div>
                    <div class="col-md-6" style="padding-right: 0;"><p style="font-weight: bold; color: #666666; padding: 8px; margin-bottom:0;">Remove</p></div>
                <div class="row" ng-repeat="item in addedMenuitems">
                    <div class="col-md-6" style="min-height: 40px;padding-top: 10px;">
                        <b style="text-transform: capitalize;">{{item.menu_name}}</b>
                        <div class="input-group bootstrap-touchspin">
                            <span class="input-group-btn">
                                <button class="btn btn-default bootstrap-touchspin-down" ng-click="item.count = item.count - 1" ng-init="item.count = 1" type="button">-</button>
                            <span class="input-group-addon bootstrap-touchspin-prefix" style="display: none;"></span>
                            <input type="text" ng-value="1" ng-model="item.count" name="count" id="count" data-bts-min="0" data-bts-max="100" data-bts-init-val="" data-bts-step="1" data-bts-decimal="0" data-bts-step-interval="100" data-bts-force-step-divisibility="round" data-bts-step-interval-delay="500" data-bts-prefix="" data-bts-postfix="" data-bts-prefix-extra-class="" data-bts-postfix-extra-class="" data-bts-booster="true" data-bts-boostat="10" data-bts-max-boosted-step="false" data-bts-mousewheel="true" data-bts-button-down-class="btn btn-default" data-bts-button-up-class="btn btn-default" class="form-control" style="display: block;padding: 6px 10px;text-align: center;width: 40px;">
                            <span class="input-group-addon bootstrap-touchspin-postfix" style="display: none;"></span>
                            <span class="input-group-btn">
                                <button class="btn btn-default bootstrap-touchspin-up" type="button" ng-click="item.count = item.count + 1" ng-init="item.count = 1">+</button>

                    ***<input type="hidden" name="menu_id[]" id="menu_id" ng-model="item.menu_id[$index + 1]">***

                    <div class="col-md-6" style="min-height: 40px;padding-top: 10px; text-align: center;">
                        <i style="cursor:pointer;" ng-click="removeMenuitem(item.menu_id)" class="fa fa-trash text-danger fa-lg" aria-hidden="true"></i>


    $scope.item = {};
 $scope.makeBilling = function () {
       method: 'post',
       url: 'menu/billing',
       data: $scope.item,
       headers: {'Content-Type': 'application/json'}
   }).success(function (data)
       if(data == 2){
            alert("Something went wrong! Please try again.");
       }else if(data == 3){
           $scope.billing_error = "Please Add some item to make the Bill.";
       }else if(data == 1){
           alert("Bill Processed Successfully");


Codeigniter Controller Function:-

  function billing(){
    $request = json_decode(file_get_contents('php://input'), TRUE);
    echo '<pre>';