di-patterns

di-patterns is an agent for coding agents from SAP/fundamental-ngx. It costs 0 tokens per session (2,439 once invoked), scanned A, original, Apache-2.0.

A guide to Angular dependency injection patterns using InjectionToken, a named way to provide configuration or values to components. The patterns let parent components supply defaults that child components can override.

In plain words
What is it for?
Use it when building Angular components that need configurable defaults or composition. It covers parent-provided settings, component composition, and updating signal-based inputs programmatically.
Why use it?
It avoids tightly connecting parent and child components or manually changing every child input. Shared settings such as themes, sizes, and behaviours can be provided in context.

Agent

About the project

Fundamental Library for Angular is an SAP-maintained Angular component library implementing SAP's design system and wrapping UI5 Web Components. Angular developers use its typed UI components and higher-level composites to build SAP-style web interfaces. Catalogue entries provide skills, agents, instructions, and a rule for working with the library.

SAP/fundamental-ngx · 294 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/sap/fundamental-ngx/di-patterns
Clone the repo
git clone --depth 1 https://github.com/SAP/fundamental-ngx

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for di-patterns

README.md
[![agentmods](https://agentmods.dev/badge/agents/sap/fundamental-ngx/di-patterns.svg)](https://agentmods.dev/agents/sap/fundamental-ngx/di-patterns)
Your own site
<a href="https://agentmods.dev/agents/sap/fundamental-ngx/di-patterns"><img src="https://agentmods.dev/badge/agents/sap/fundamental-ngx/di-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,439 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.02439
Opus 5 $0.00000 $0.01220
Sonnet 5 $0.00000 $0.00488
Haiku 4.5 $0.00000 $0.00244

Measured 4d ago against content hash 659b27dccaec, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

di-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/agents/di-patterns.md · 340 lines

How it starts

The opening of the file, as written. The whole thing — 340 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Dependency Injection Patterns

This document covers advanced dependency injection patterns for Angular 22+ development in Fundamental NGX.

Table of Contents


Pattern 1: Contextual Defaults with InjectionTokens

Use InjectionToken to provide contextual defaults for child components. This pattern allows parent components to influence default values without directly manipulating child component inputs.

When to use

  • Parent components need to provide default configurations to unknown child components
  • Setting framework-level defaults (themes, sizes, behaviors)
  • Avoiding tight coupling between parent and child components
  • Providing optional configuration that children can override

Implementation

Step 1: Define the token (in child component file)

// title.component.ts
import { InjectionToken } from '@angular/core';

export type HeaderSizes = 1 | 2 | 3 | 4 | 5 | 6;

export const DEFAULT_TITLE_SIZE = new InjectionToken<HeaderSizes>('DEFAULT_TITLE_SIZE');

Step 2: Child component injects optional default

@Component({
    selector: '[fd-title]'
})
export class Title {
    readonly headerSize = input<HeaderSizes | null>(null);

    private readonly _defaultHeaderSize = inject(DEFAULT_TITLE_SIZE, { optional: true });

    // Compute the effective size: explicit input > injected default > element tag name
    protected readonly _effectiveSize = computed(
        () => this.headerSize() ?? this._defaultHeaderSize ?? this._detectSize()
    );

    // Use effect only for the imperative DOM side effect
    constructor() {
        effect(() => {
            const size = this._effectiveSize();
            untracked(() => this._applySize(size));
        });
    }

    private _detectSize(): HeaderSizes {
        // Fallback logic
        return 3;
    }
}

Read the full file on GitHub · 340 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 340 lines · 0 tokens per session scan A 659b27dccaec

Subscribe to this mod's changes

di-patterns is an agent published in the GitHub repository SAP/fundamental-ngx (294 stars, last pushed today), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 2,439 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.