html - Updating value which depends on changing of another value, and vice versa -


i have kind of problem. can't find solution on web. have value depends on modification of value. , vice versa. code

<div class="panel-body">         <div class="row">             <label class="col-lg-2 label-margin"> fondo bucket 1 (eur)</label>             <div class="col-lg-1 right-col-margin">{{::fondo.fnd1}}</div> ---> input             <label class="col-lg-2 label-margin"> fondo bucket 2 (eur)</label>             <div class="col-lg-7 right-col-margin">{{::fondo.fnd2}}</div> ---> input         </div>             <div class="row">             <label class="col-lg-2 label-margin"> fondo bucket 1 (div)</label>              <div class="col-lg-1 right-col-margin">{{::fondo.fnd1div}}</div> ---> input             <label class="col-lg-2 label-margin"> fondo bucket 2 (div)</label>             <div class="col-lg-7 right-col-margin">{{::fondo.fnd2div}}</div> ---> input         </div>         <div class="row">             <label class="col-lg-2 label-margin"> bucket dh </label>             <div class="col-lg-1 right-col-margin">{{::fondo.bktdh}}</div>             <label class="col-lg-2 label-margin"> cambio </label>             <div class="col-lg-7 right-col-margin">{{::fondo.cambio}}</div>         </div>     </div> 

my wish being able edit fields fondo.fnd1, fondo.fnd2, fondo.fnd1div , fondo.fnd2div, but... if edit fondo.fnd1 , fondo.fnd2 new value of fondo.fnd1div must division between fondo.fnd1 , fondo.cambio , new value of fondo.fnd2div must division between fondo.fnd2 , fondo.cambio (i can modify 1 of these 2 fields). instead, if modify fondo.fnd1div , fondo.fnd2div new value of fondo.fnd1 must multiplication between fondo.fnd1div , cambio, , new value of fondo.fnd2div must multiplication of fondo.fnd2 , cambio. need immediate update , avoid "tragic" loop. know must use ng-change, don't know how use it. thank in advance.

there many different event listeners available in angular. in particular, there 4 main listeners can used in scenario, , each operates differently.

ng-keyup

this event used when want fire function in response user releases key. differs ng-keypress, fires when key pressed, fires continually if key held down.

ng-blur

this event used when want detect if focused input on form "blurred", or in other words, if focus changes 1 input another. fire once entire input interaction.

ng-change

this event fires whenever new value committed model. fire when change occurs model, , not fire when conditions true, such input form value being invalid or null.

note of these listeners fire under specific conditions on input fields, , none of them fire due programmatic changes model value. therefore, cannot stuck in loop changing value causes event fire causes change. happen other frameworks, changed dom directly.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -