2016-03-20 16 views
1

html'deki angularjs'den ng-yineleme işleviyle ilgili bir sorunum var. Her bir cartproduct'daki 'add-price' ibaresi ile girdim aynı şekilde değişir, örneğin 1'den 2'ye kadar ilk cartproduct değerini ikinci, üçüncü ve diğer cartproducts değerleri de 1'den 2'ye arttırır.Girdi değerlerindeki değişiklik angularjs/html

<tr ng-repeat="cartproduct in store.cartproducts" bs-popover> 
    <td>{{cartproduct.cartname}}</td> 
    <td>{{cartproduct.cartbrutto}}</td> 
    <td> 
     <div class="form-group"> 
      <input id="add-price" class="form-control" type="number" min="1" step="any" name="counter" ng-model="product.counter" ng-change="store.calculateRow(cartproduct.cartbrutto)" placeholder="1"> 
     </div> 
    </td> 
    <td> 
     <div class="form-group"> 
      <input id="add-final-price" class="form-control" type="text" name="row" ng-model="product.row" placeholder="{{cartproduct.cartbrutto}}"> 
     </div> 
    </td> 
</tr> 

Yardım edin:

İşte benim kodudur!

Saygılar!

cevap

0

Onun, çünkü ben yapmak olduğunu söyleyebilirim her ng-model

üzerinde counter aynı referans paylaşan aynı yerde güncellenmesi counter değeri göreli yerine product

İşaretleme onu sahip cartproduct o

<input id="add-price" class="form-control" type="number" min="1" 
step="any" name="counter" ng-model="cartproduct.counter" 
ng-change="store.calculateRow(cartproduct.cartbrutto)" placeholder="1"> 
+0

OMG, ne aptal bir hata. Diğer ng-tekrar fonksiyonunda ürünüm vardı ve buraya kopyaladım. İsim değiştirmediğimi fark etmemiştim. Çok teşekkürler! – johnpol23

+0

@ johnpol23 İşe yaradığını duyduğuma sevindim .. Teşekkürler :-) Cevap kabul etmeyi unutmayın .. Teşekkürler :-) –