Angular2 ngModelChange previous value

前端 未结 4 1547
醉酒成梦
醉酒成梦 2020-12-25 11:13

Is there a way to get the previous(last) value of a field on ngModelChange? What I have goes something like this

HTML



        
4条回答
  •  时光取名叫无心
    2020-12-25 11:41

    So found kinda weird(at least for me) possible solution for this with least changes in the code in question. So on assigning the (ngModelChange) attribute before [(ngModel)] what I get is following with the same handler:

    changed *older value* *new value*
    

    I get the new value in this.textlike so:

    setTimeout(() => console.log(this.text), 0);
    

提交回复
热议问题