Extending the Activity Log

Reacting to the Form Model changes is not the only thing we can do; we can extend our subscriptions to observe any form control as well. Let's perform a further upgrade on our current Activity Log implementation to demonstrate that. 

Open the /ClientApp/src/app/cities/city-edit.component.ts class file and update the code in the constructor method with the following highlighted lines:

// ...existing code...// react to form changesthis.form.valueChanges  .subscribe(val => {    if (!this.form.dirty) {      this.log("Form Model has been loaded.");    }    else {      this.log("Form was updated by the user.");    }  });// react to changes in the form.name controlthis.form.get("name")!.valueChanges  .subscribe(val => { if (!this.form.dirty) { ...

Get ASP.NET Core 3 and Angular 9 - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.