angularjs - Change ng-modal input value with another input in-modal -


i want change value of input has ng-model input ng-model value. not so. ng-model="quantity" in ng-repeat, , ng-model="power" outside of ng-repeat. when change value in power quantity should change accordingly.

e.g

 <input type="text" ng-model="quantity" value="{{quantity * power}}">  <input type="text" ng-model="power" value="{{power}}">  

try this.

angular.module('myapp', []).controller('mainctrl', function ($scope) {          $scope.quantities = [25, 6, 6.5, 80];          $scope.quantitiesnewvalue = [25, 6, 6.5, 80];          $scope.power = 1;        $scope.setvalue = function(power){        angular.foreach($scope.quantities, function(quantity,i){           $scope.quantitiesnewvalue[i] = power * quantity;          });       }                         })
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>  <div ng-app="myapp" ng-controller="mainctrl">  <h1>ng-model sample</h1>  <p><input type="text" ng-model="power" ng-change="setvalue(power)" value="{{power}}" /></p>  <div ng-repeat="quantity in quantitiesnewvalue">  quantity: <input type="text" ng-model="quantity" />  </div>


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -