"Gold loan management system"というプロジェクトに取り組んでいます。 Form fields to insert the ornament name and weight.Total number of ornaments and total weight is calculated automatically .Iは---Angular jsを使用して配列内の値の合計を動的に計算する
index.htmlを
<fieldset data-ng-repeat="choice in choices">
<div class="form-group">
<select class="form-control" name="optioin" ng-model="choice.option" >
<option value="Ring">Ring</option>
<option value="Earings">Earings</option>
<option value="Chains">Chains</option>
<option value="Necklaces">Necklaces</option>
<option value="Bangles">Bangles</option>
</select>
</div>
<div class="form-group">
<input class="form-control" type="number" ng-model="choice.weight" name="" placeholder="Enter the weight">gm
<button class="btn btn-default" ng-show="$last" ng-click="removeChoice() "><span class="glyphicon glyphicon-minus" aria-hidden="true"></span></button>
<button class="btn btn-default" ng-show="$last" ng-click="addNewChoice()"> <span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
</div>
</fieldset>
</form>
<form class="form-inline">
<div class="form-group">
<label for="totnumber">Total Nos:</label>
<input type="number" ng-model="choices.length" class="form-control" id="totnumber">
</div>
<div class="form-group">
<label for="totweight">Total Weight:</label>
<input type="number" ng-model="total" class="form-control" id="totweight">
</div>
</form>
dashboardcntrl.js
app.controller('dashboardCtrl', function($scope) {
$scope.choices = [{id: 'choice1'}];
$scope.addNewChoice = function() {
var newItemNo = $scope.choices.length+1;
$scope.choices.push({'id':'choice'+newItemNo});
console.log( $scope. choices.length);
};
$scope.removeChoice = function() {
var lastItem = $scope.choices.length-1;
$scope.choices.splice(lastItem);
console.log( $scope. choices.length);
};
});
どのようにdynamically.Hereが私のコードである総重量を計算することができませんでした私がする?
** $ **最後に言及? – Aravind