0

I need five independent fields based on the actual price and offer i need to find final price This is my sample html code

addproduct.html

    <tbody ng-repeat="a in [1,2,3,4,5]">
       <tr>
         <th scope="row">{{a}}</th>
         <td><input type="text" class="form-control" placeholder="0" style="width:70%; line-height:1.5" ng-model="product.pModel"></td>
         <td><input type="text" class="form-control" placeholder="0" style="width:70%; line-height:1.5" ng-model="product.actualPrice" max="2" limit-decimal></td>
         <td><input type="text" class="form-control" placeholder="0" style="width:50%; line-height:1.5" ng-model="product.offer" numbers-only></td>        
         <td>
             <label class="checkbox-inline" ng-init="data.check=true">
                  <input type="checkbox" id="inlineCheckbox" value="option" ng-change="product.availablity = data.check ? '' : 0" ng-model="data.check"> Unlimited
            </label>
        </td>
        <td><input class="form-control" type="text" id="availablity" name="availablity" ng-disabled="data.check0" ng-model="product.availablity" ></td>
        <td class="text-center"> <b ng-model="finalPrice"  ng-bind="finalPrice=product.actualPrice-(product.actualPrice*product.offer/100)"></b></td>        
      </tr> 

    </tbody>

How can i save data in json format using angularjs

When I save the submit button I need the output as

script.json

    product : [
            {
                "pModel" : "50gm",
                "actualPrice" : "250",
                "offer" : 0,
                "availablity" : "0"
            },
            {
                "pModel" : "50gm",
                "actualPrice" : "250",
                "offer" : 0,
                "availablity" : "0"
            }
                .....upto 5 fields           
            ]

In here when I am entering any one of the field it will affect entire field

1
  • Create a plunker of what you have tried Commented Mar 11, 2016 at 11:29

1 Answer 1

0

This should help you to figure it out.

Your product variable is an array, so you should access it like it's array, not as object - product[$index].fieldName

Sign up to request clarification or add additional context in comments.

Comments

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.