Detecting changes of an object angular 2 -


i know if object myobject has been modified in view , purpose using ngonchanges.

this html

  <form class="inputform">     <table id="inputformtable">       <tr>         <td><label>login</label></td>         <td><input type="text" size="40" [(ngmodel)]="myobject.value1" name="value1"/></td>       </tr>       <tr>         <td><label>mot de passe</label></td>         <td><input type="password" size="40" [(ngmodel)]="myobject.value2" name="value2"/></td>       </tr>     </table> 

this component using ngonchanges

import {component, oninit, onchanges, simplechanges, input} '@angular/core'; export class utilisateurcomponent implements oninit, onchanges {   @input() myobject: any= {actif: false};   ngonchanges(changes: simplechanges): void {     (let propname in changes) {       let chng = changes[propname];       let cur = json.stringify(chng.currentvalue);       let prev = json.stringify(chng.previousvalue);       console.log(`${propname}: currentvalue = ${cur}, previousvalue = ${prev}`);     }   } } 

when myobject properties (value1 , value2) change, trigger ngonchanges. have done far, unable so. in advance help!

ngonchanges in used when @input value component changes. understand code, ngmodelchange want.


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? -