html - Angular JS Form Calculation -


i'm new angular.js, , want calculate form fields, able calculate $scope.piece , output results html. problem cannot calculate $scope.$scope.typeofwritings. how can value of $scope.typeofwritings. $scope.calculation = ($scope.piece * $scope.typeofwritings);

(function(angular) {    'use strict';  angular.module('formexample', ['ngmessages'])    .controller('examplecontroller', ['$scope', function($scope) {    $scope.typeofwritings = [{  			value: '5',  			text: 'writing scratch'  		  }, {  			value: '3',  			text: 'editing or proofreading'  		  }  		  ];  		    $scope.pieces = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];  $scope.piece = 1;    		$scope.calculate = function(){  		$scope.calculation = $scope.piece;  		  		}  		$scope.calculate();  		    	    }]);  })(window.angular);
<tr>        <td width="186"><label for="type_writing">type of writing:</label></td>        <td width="269"><select ng-change="calculate()" ng-model="type_writing" ng-options="o.value o.text o in typeofwritings" ng-init="type_writing='5'" name="type_writing" id="type_writing">        </select>        </td>  </tr>    <tr>        <td><label for="length">article length:</label></td>        <td><select ng-model="length" ng-options="o.value o.text o in lengths" ng-init="length='1'" name="length" id="length">        </select></td>  </tr>    <tr>             <td><strong>order cost</strong><div style="color:#d76d25; font-size:24px;">${{calculation}}</div></td>      </tr>  <tr>

to value in array of object can follows:

scope.calculation = ($scope.piece * $scope.typeofwritings[0].value); // 1*5 scope.calculation = ($scope.piece * $scope.typeofwritings[1].value);// 1*3 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -