Angular 2 rollback model state in forms

后端 未结 2 905
忘了有多久
忘了有多久 2021-01-27 00:56

I have a form in Angular 2 which is bound to a model. Now I want the changes in the model to rollback when the user hits cancel. How do I achieve this?

2条回答
  •  无人及你
    2021-01-27 01:38

    If you make a copy of your model by doing Object.assign({}, yourModel) you won't mutate the original object, which will allow you to revert to the original object.

提交回复
热议问题