MCPcopy Create free account
hub / github.com/angular/components / ngDoCheck

Method ngDoCheck

src/material/input/input.ts:386–411  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

384 }
385
386 ngDoCheck() {
387 if (this.ngControl) {
388 // We need to re-evaluate this on every change detection cycle, because there are some
389 // error triggers that we can't subscribe to (e.g. parent form submissions). This means
390 // that whatever logic is in here has to be super lean or we risk destroying the performance.
391 this.updateErrorState();
392
393 // Since the input isn't a `ControlValueAccessor`, we don't have a good way of knowing when
394 // the disabled state has changed. We can't use the `ngControl.statusChanges`, because it
395 // won't fire if the input is disabled with `emitEvents = false`, despite the input becoming
396 // disabled.
397 if (this.ngControl.disabled !== null && this.ngControl.disabled !== this.disabled) {
398 this.disabled = this.ngControl.disabled;
399 this.stateChanges.next();
400 }
401 }
402
403 // We need to dirty-check the native element's value, because there are some cases where
404 // we won't be notified when it changes (e.g. the consumer isn't using forms or they're
405 // updating the value using `emitEvent: false`).
406 this._dirtyCheckNativeValue();
407
408 // We need to dirty-check and set the placeholder attribute ourselves, because whether it's
409 // present or not depends on a query which is prone to "changed after checked" errors.
410 this._dirtyCheckPlaceholder();
411 }
412
413 /** Focuses the input. */
414 focus(options?: FocusOptions): void {

Callers

nothing calls this directly

Calls 4

updateErrorStateMethod · 0.95
nextMethod · 0.45

Tested by

no test coverage detected