MCPcopy
hub / github.com/angular/angular / throwErrorIfNoChangesMode

Function throwErrorIfNoChangesMode

packages/core/src/render3/errors.ts:65–86  ·  view source on GitHub ↗
(
  creationMode: boolean,
  oldValue: any,
  currValue: any,
  propName: string | undefined,
  lView: LView,
)

Source from the content-addressed store, hash-verified

63
64/** Throws an ExpressionChangedAfterChecked error if checkNoChanges mode is on. */
65export function throwErrorIfNoChangesMode(
66 creationMode: boolean,
67 oldValue: any,
68 currValue: any,
69 propName: string | undefined,
70 lView: LView,
71): never {
72 const hostComponentDef = getDeclarationComponentDef(lView);
73 const componentClassName = hostComponentDef?.type?.name;
74 const field = propName ? ` for '${propName}'` : '';
75 let msg = `ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value${field}: '${formatValue(
76 oldValue,
77 )}'. Current value: '${formatValue(currValue)}'.${
78 componentClassName ? ` Expression location: ${componentClassName} component` : ''
79 }`;
80 if (creationMode) {
81 msg +=
82 ` It seems like the view has been created after its parent and its children have been dirty checked.` +
83 ` Has it been created in a change detection hook?`;
84 }
85 throw new RuntimeError(RuntimeErrorCode.EXPRESSION_CHANGED_AFTER_CHECKED, msg);
86}
87
88function formatValue(value: unknown): string {
89 let strValue: string = String(value);

Callers 1

bindingUpdatedFunction · 0.90

Calls 2

formatValueFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…