2016-07-31 12 views
-2
<body ng-controller="testeCtrl"> 
    <img src="http://adsim.co/wp-content/uploads/2015/11/adsim_logo_cores_2x.png" alt="#" class="logo"> 
    <div class="jumbotron barraPrincipal" ng-app="teste"> 
    <div class="table-responsive"> 
     <table class="table"> 
     <tr ng-repeat="i in getNumber(number) track by $index"> 
      <th> 
      <select class="logo form-control" ng-model="refrigerante" ng-options="refrige as (refrige.nome+' '+refrige.quantidade) for refrige in refri"> 
       <option value=""> 
       <h4>Selecione o refrigerante</h4></option> 
      </select> 
      </th> 
      <th> 
      <input class="form-control" type="number" min="1" placeholder="Informe a quantidade" ng-model="quantidade"></input> 
      </th> 
      <th> 
      <h4>Valor Unitário: {{refrigerante.preco | currency:'R$' }}</h4> 
      </th> 

      <th> 
      <h4 ng-show="refrigerante != null && quantidade > 0 && quantidade != 0" ng-model="i.fields[$index].item_count" name="item_count">Valor dos produtos: {{va = quantidade*refrigerante.preco | currency:'R$'}} </h4></th> 
     </tr> 
     <tr> 
      <td></td> 
      <td></td> 
      <td></td> 
      <!-- total value of refrigerante.preco*quantidade here --> 
      <td>Valor total <span> </span></td> 
     </tr> 
     </table> 
    </div> 
    </div> 
    </div> 
</body> 
+1

スタックオーバーフローが、一般的にポストが英語であることを期待していません。 [Stack Overflow emPortuguês](https://pt.stackoverflow.com/)を試してください。 –

答えて

0

何かを合計したい場合、ng-repeatはおそらく役に立ちません。あなたは、フィルタを定義したり、HTMLで次のようにスコープの関数を呼び出すことができます:{{calculateSum()}}

https://docs.angularjs.org/api/ng/filter/filter

0

まず、あなたはそれらのいずれか、あなたのHTMLで意味エラーがたくさんあります<input>タグです。 自己閉鎖タグなので、閉じる必要はありません。そして、それを呼び出す

$scope.total = function(refrigerante, quantidade) { 
    return refrigerante.preco * quantidade;  
} 

:また、あなただけ以下のように、あなたのコントローラfunctionを作成あなたが望むものを達成するために... ngRepeat外の合計値を取得するために

をしようとしていますあなたのビューに:

<tr ng-repeat="i in getNumber(number) track by $index"> 
    ... 
    <td ng-bind="'Valor total ' + total()"></td> 
    <!-- Or --> 
    <td>Valor total {{total()}}</td> 
</tr>