@memberjunction/ng-container-directives
Version:
MemberJunction: Angular Container Directives - Fill Container for Auto-Resizing, and plain container just for element identification/binding
34 lines • 1.43 kB
JavaScript
import { Directive } from '@angular/core';
import * as i0 from "@angular/core";
/**
* Directive that exposes a ViewContainerRef for dynamic component loading.
* This is used to create a reference point for dynamically loading components
* into the DOM without manually handling ViewContainerRef injection.
*
* @example
* <!-- In template -->
* <div mjContainer></div>
*
* <!-- In component -->
* @ViewChild(Container, { static: true }) container!: Container;
* // Now you can use this.container.viewContainerRef for dynamic component creation
*/
export class Container {
viewContainerRef;
/**
* Constructor that exposes the ViewContainerRef for the element
* @param viewContainerRef The ViewContainerRef for the element this directive is applied to
*/
constructor(viewContainerRef) {
this.viewContainerRef = viewContainerRef;
}
static ɵfac = function Container_Factory(t) { return new (t || Container)(i0.ɵɵdirectiveInject(i0.ViewContainerRef)); };
static ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: Container, selectors: [["", "mjContainer", ""]] });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Container, [{
type: Directive,
args: [{
selector: '[mjContainer]',
}]
}], () => [{ type: i0.ViewContainerRef }], null); })();
//# sourceMappingURL=ng-container-directive.js.map