# @memberjunction/ng-container-directives Angular directives for container management in MemberJunction applications -- `mjContainer` for dynamic component loading via ViewContainerRef, and `mjFillContainer` for automatic element resizing to fill parent containers. ## Overview This package provides two essential layout directives. `mjContainer` exposes a `ViewContainerRef` for programmatic component creation. `mjFillContainer` automatically calculates and sets element dimensions based on the parent container, with context-aware behavior that skips resizing inside grids, hidden tabs, or elements marked with `mjSkipResize`. ```mermaid graph TD A[ContainerDirectivesModule] --> B["mjContainer Directive"] A --> C["mjFillContainer Directive"] B --> B1["Exposes ViewContainerRef"] B --> B2["Dynamic Component Loading"] C --> C1["Auto Width/Height Calculation"] C --> C2["Window Resize Handling (dual debounce)"] C --> C3["MJGlobal Manual Resize Events"] C --> C4["Context-Aware Skipping (grids, hidden tabs, mjSkipResize)"] style A fill:#2d6a9f,stroke:#1a4971,color:#fff style B fill:#7c5295,stroke:#563a6b,color:#fff style C fill:#2d8659,stroke:#1a5c3a,color:#fff ``` ## Installation ```bash npm install @memberjunction/ng-container-directives ``` ## Usage ### Import the Module ```typescript import { ContainerDirectivesModule } from '@memberjunction/ng-container-directives'; @NgModule({ imports: [ContainerDirectivesModule] }) export class YourModule { } ``` ### mjContainer Exposes a `ViewContainerRef` for dynamic component loading: ```html
``` ```typescript import { Container } from '@memberjunction/ng-container-directives'; @Component({ selector: 'app-dynamic-host', template: `` }) export class DynamicHostComponent { @ViewChild(Container, { static: true }) container!: Container; ngOnInit() { const ref = this.container.viewContainerRef; // ref.createComponent(YourDynamicComponent); } } ``` ### mjFillContainer Automatically resizes an element to fill its parent: ```html