Answer the question
In order to leave comments, you need to log in
How to change the value of a field relative to the value of another field in Angular?
Good day. I need help with Angular. There is a project on Laravel. There are two fields. The first field is the number of participants. The second is the amount per participant.
<input type="number" ng-model="model.amount_users">
<input type="text" ng-model="model.price">
Answer the question
In order to leave comments, you need to log in
There are several options:
1. ng-change:
<input type="number" ng-model="model.amount_users" ng-change="onUserAmountChange()">
<input type="text" ng-model="model.price">
$scope.onUserAmountChange = function() {
$scope.model.price = FULL_PRICE/$scope.model.amount_users;
}
<input type="number" ng-model="model.amount_users" ng-change="onUserAmountChange()">
<span> {{model.fullPrice/model.amount_users}} </span>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question