是否有任何方便的方法来检查我的应用程序模型是否已被用户更改?我需要它来向用户指示未保存的更改。
值得一提的是,我在应用程序中没有使用任何表单,并且我的 model
从应用程序的根组件向下渗透到子组件,这意味着它可能会发生突变下面也有。
最佳答案
我认为你需要看看 ngModelChange,以及 Angular 中的一般更改检测。
https://angular.io/docs/ts/latest/api/forms/index/FormControl-class.html
http://blog.thoughtram.io/angular/2016/02/22/angular-2-change-detection-explained.html
由于 $digest 机制现在也是“区域”(onTurnDone),因此了解它们的一些信息非常有用。
http://blog.thoughtram.io/angular/2016/02/01/zones-in-angular-2.html
关于javascript - 检查型号 "dirtiness",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41534969/