Hi Alain Chautard

Here is html  to add a new item.

    <div class="list">
      <div class="row" ng:repeat="item in invoice.items">
        <div class="col col-50">
          <ion-autocomplete name="product" ng-model="item.productId" 
item-value-key="productId"
            item-view-value-key="productName" items-method=
"getProducts(query)"
            items-method-value-key="items" items-clicked-method=
"productClickCallBack(callback)" 
            ng-value="calculateAll()" placeholder="Product Or Service" 
required/>
        </div>
        <div class="col">
          <input type="number" maxlength="4" placeholder="Qty"
            ng-model="item.qty" ng-change="calculateAll()">
        </div>
        <div class="col">
          <input type="number" maxlength="6" placeholder="Unit Cost"
            ng-model="item.unitCost" ng-change="calculateAll()">
        </div>
      </div>
      <div class="row">
        <span style="color:red" ng-show="submitted && 
(salesInvoice.product.$error.required && itemRowIndex == 0)">
          Please select alteast one lineItem.
        </span>
      </div>
      <div class="row">
        <div class="col col-50" ng-hide="invoiceSaved === true">
          <button class="button button-clear button-positive" ng-click=
"addItem()">Add Item</button>
        </div>
      </div>

Here is js code:

   $scope.addItem = function() {
      console.log("itemRowIndex :" + $scope.itemRowIndex);
      $scope.item = {};
      $scope.invoice.items.push($scope.item);
      $scope.itemRowIndex += 1;
    };



Here is product click call back function: which is called when selecting a 
product.

<ion-autocomplete name="product" ng-model="item.productId" item-value-key=
"productId"
            item-view-value-key="productName" items-method=
"getProducts(query)"
            items-method-value-key="items" items-clicked-method=
"productClickCallBack(callback)" 
            placeholder="Product Or Service"/>

$scope.productClickCallBack = function(callback) {
      console.log("productClickCallBack :" + JSON.stringify(callback.item));
      $scope.item.qty = 1;
      $scope.item.unitCost = callback.item.sellingPrice;
      console.log("unitPrice :" + $scope.item.unitCost);
    };






On Monday, June 15, 2015 at 10:39:14 PM UTC+5:30, Alain Chautard wrote:
>
> Could you show the code used to add a new item? (both HTML and JS)
> I believe that's where the issue is.
>
> On Friday, June 12, 2015 at 12:07:44 AM UTC-7, Yogesh N wrote:
>>
>>
>>
>>   
>>   
>> I'm trying to select a product from the suggest box. When a select a 
>> product, the qty and unit cost as to appear in the text box automatically 
>> which is done using angularjs ng-model. The Add Item in the image will add 
>> an empty row, where we can select product/service for invoice. 
>>
>> Now the issue is, when i click Add Item twice and select product/service 
>> in the first row, qty and unit cost is updated for the 2nd row. Can anyone 
>> help me out in this issue Thanks in advance.
>>
>>
>>
>> Here is my html:
>>
>>
>>       <div class="row" ng:repeat="item in invoice.items">
>>         <div class="col col-50">
>>           <ion-autocomplete name="product" ng-model="item.productId" 
>> item-value-key="productId"
>>             item-view-value-key="productName" items-method=
>> "getProducts(query)"
>>             items-method-value-key="items" items-clicked-method=
>> "productClickCallBack(callback)" 
>>             ng-value="calculateAll()" placeholder="Product Or Service" 
>> required/>
>>         </div>
>>         <div class="col">
>>           <input type="number" maxlength="4" placeholder="Qty"
>>             ng-model="item.qty" ng-change="calculateAll()">
>>         </div>
>>         <div class="col">
>>           <input type="number" maxlength="6" placeholder="Unit Cost"
>>             ng-model="item.unitCost" ng-change="calculateAll()">
>>         </div>
>>       </div>
>>
>>  
>>   
>> <https://lh3.googleusercontent.com/-2mUl4MZXjGA/VXqFG1PV1AI/AAAAAAAAADI/mxq38yZ88Vs/s1600/Screenshot_2015-06-12-11-44-32.png>
>>
>> I'm trying to select a product from the suggest box. When a select a 
>> product, the qty and unit cost as to appear in the text box automatically 
>> which is done using angularjs ng-model. The Add Item in the image will add 
>> an empty row, where we can select product/service for invoice. 
>>
>> Now the issue is, when i click Add Item twice and select product/service 
>> in the first row, qty and unit cost is updated for the 2nd row. Can anyone 
>> help me out in this issue Thanks in advance.
>>
>> Here is my html:
>>
>>
>> <div class="row" ng:repeat="item in invoice.items">
>>     <div class="col col-50">
>>       <ion-autocomplete name="product" ng-model="item.productId" 
>> item-value-key="productId"
>>         item-view-value-key="productName" items-method="getProducts(query)"
>>         items-method-value-key="items" 
>> items-clicked-method="productClickCallBack(callback)" 
>>         ng-value="calculateAll()" placeholder="Product Or Service" required/>
>>     </div>
>>     <div class="col">
>>       <input type="number" maxlength="4" placeholder="Qty"
>>         ng-model="item.qty" ng-change="calculateAll()">
>>     </div>
>>     <div class="col">
>>       <input type="number" maxlength="6" placeholder="Unit Cost"
>>         ng-model="item.unitCost" ng-change="calculateAll()">
>>     </div>
>>   </div>
>>
>>
>>
>> Here is productClickCallBack(callback) method definition:
>>
>>
>>    $scope.productClickCallBack = function(callback) {
>>       $scope.item.qty = 1;
>>       $scope.item.unitCost = callback.item.sellingPrice;
>>     };
>>
>>
>>  

>
>> <https://lh3.googleusercontent.com/-2mUl4MZXjGA/VXqFG1PV1AI/AAAAAAAAADI/mxq38yZ88Vs/s1600/Screenshot_2015-06-12-11-44-32.png>
>>
>>
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to