As I fill out values in this form and click create button
The data will insert into database, and the result will show in data grid which implement by AngularJS ng-grid.
As I click specific data row, the afterSelectionChange event will be triggered.
Owing to "預算別" and "債務別" are cascading dropdown list, the second dropdown list options will change as the value of the first dropdown list changed.
Therefore, we will watch the second dropdown list and fill in values in the form.
The problem is......if I just change the second dropdown list instead of click data grid, it will also go into watch. Because of it had start to watch, if you change the value of the second dropdwon list, it will call the watch code even you don't trigger afterSelectionChange.
Here is the code snippet
Therefore, we need to unregister watch if we do not need to watch.
Here is the revised code snippet