| 262 | } |
| 263 | |
| 264 | ngAfterViewChecked() { |
| 265 | // Since parent components could be using the option's label to display the selected values |
| 266 | // (e.g. `mat-select`) and they don't have a way of knowing if the option's label has changed |
| 267 | // we have to check for changes in the DOM ourselves and dispatch an event. These checks are |
| 268 | // relatively cheap, however we still limit them only to selected options in order to avoid |
| 269 | // hitting the DOM too often. |
| 270 | if (this._selected) { |
| 271 | const viewValue = this.viewValue; |
| 272 | |
| 273 | if (viewValue !== this._mostRecentViewValue) { |
| 274 | if (this._mostRecentViewValue) { |
| 275 | this._stateChanges.next(); |
| 276 | } |
| 277 | |
| 278 | this._mostRecentViewValue = viewValue; |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | ngOnDestroy() { |
| 284 | this._stateChanges.complete(); |