* Applies the changes when needed. * @docs-private
()
| 251 | * @docs-private |
| 252 | */ |
| 253 | ngDoCheck(): void { |
| 254 | if (this._ngForOfDirty) { |
| 255 | this._ngForOfDirty = false; |
| 256 | // React on ngForOf changes only once all inputs have been initialized |
| 257 | const value = this._ngForOf; |
| 258 | if (!this._differ && value) { |
| 259 | if (typeof ngDevMode === 'undefined' || ngDevMode) { |
| 260 | try { |
| 261 | // CAUTION: this logic is duplicated for production mode below, as the try-catch |
| 262 | // is only present in development builds. |
| 263 | this._differ = this._differs.find(value).create(this.ngForTrackBy); |
| 264 | } catch { |
| 265 | let errorMessage = |
| 266 | `Cannot find a differ supporting object '${value}' of type '` + |
| 267 | `${getTypeName(value)}'. NgFor only supports binding to Iterables, such as Arrays.`; |
| 268 | if (typeof value === 'object') { |
| 269 | errorMessage += ' Did you mean to use the keyvalue pipe?'; |
| 270 | } |
| 271 | throw new RuntimeError(RuntimeErrorCode.NG_FOR_MISSING_DIFFER, errorMessage); |
| 272 | } |
| 273 | } else { |
| 274 | // CAUTION: this logic is duplicated for development mode above, as the try-catch |
| 275 | // is only present in development builds. |
| 276 | this._differ = this._differs.find(value).create(this.ngForTrackBy); |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | if (this._differ) { |
| 281 | const changes = this._differ.diff(this._ngForOf); |
| 282 | if (changes) this._applyChanges(changes); |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | private _applyChanges(changes: IterableChanges<T>) { |
| 287 | const viewContainer = this._viewContainer; |
nothing calls this directly
no test coverage detected