2016-12-02 5 views
0

Durch AngularJS im Multiplikation zweier Werte verwenden, aber wenn ich auf Schaltfläche Hinzufügen klicken sollte seine Anzeige auf das Textfeld wieWie füge ich einen Datensatz unter Div ein?

price 10 qty 2 total 20 --->Add> 

Price qty Total 
10  2  20 

HTML-Code unten

<div class="row"> 
    <div ng-controller="Supercntrl"> 
     <div class="form-inline" id="Mom"> 
      Price <input type="text" ng-model="price" class="form-control" /> 
      quentity <input type="text" ng-model="Quantity" class="form-control" ng-change="Claci()" /> 
      Total <input type="text" ng-model="Total" class="form-control" /> 

      <input type="button" class="btn btn-sm btn-success" value="Add" ng-click="AddDetails()" /> 

     </div> 
     <div > 
//Display Insered Record 
      </div> 
    </div> 
</div> 

Controller.Js

$scope.Claci = function() { 
      if ($scope.price != null && $scope.Quantity != null) { 
       $scope.Total = $scope.price * $scope.Quantity 
      } 
     } 

bitte vorschlagen e wie kann ich dis lagen die Werte seiner

Antwort

1

HTML unten:

<div> 
    <!-- //Display Insered Record --> 
    <ul ng-repeat="total in totals"> 
     <li>Price: {{total.price}}</li> 
     <li>Quantity: {{total.quantity}}</li> 
     <li>Total: {{total.total}}</li> 
    </ul> 
</div> 

In Controller:

$scope.totals = [] 
$scope.AddDetails = function() { 
    $scope.totals.push({ 
     price: $scope.price, 
     quantity: $scope.Quantity, 
     total: $scope.Total 
    }) 
    console.log($scope.totals) 
} 

JSFiddle Demo https://jsfiddle.net/eqL7mj9r/

Verwandte Themen