MCPcopy Create free account
hub / github.com/angular/angular / extractFieldValue

Function extractFieldValue

packages/compiler/src/typecheck/ops/signal_forms.ts:441–452  ·  view source on GitHub ↗

* Gets an expression that extracts the value of a field binding.

(expression: AST, tcb: Context, scope: Scope)

Source from the content-addressed store, hash-verified

439 * Gets an expression that extracts the value of a field binding.
440 */
441function extractFieldValue(expression: AST, tcb: Context, scope: Scope): TcbExpr {
442 // Unwraps the field, e.g. `[field]="f"` turns into `f()`.
443 const innerCall = new TcbExpr(tcbExpression(expression, tcb, scope).print() + '()');
444
445 // Note: we ignore diagnostics on this call, because it might not be callable
446 // (e.g. `undefined` is passed in). Whether the value conforms to `FieldTree` is
447 // checked using the common inputs op.
448 innerCall.markIgnoreDiagnostics();
449
450 // Extract the value from the field, e.g. `f().value()`.
451 return new TcbExpr(`${innerCall.print()}.value()`);
452}
453
454/**
455 * Gets an expression that extracts the value signal of a field binding (without calling it).

Callers 1

executeMethod · 0.85

Calls 3

printMethod · 0.95
markIgnoreDiagnosticsMethod · 0.95
tcbExpressionFunction · 0.90

Tested by

no test coverage detected