' as the host element.
```html
```
--------------------------------
### Basic Lazy Element Usage in Angular
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/examples/basic/basic.component.html
Demonstrates the most basic usage of the *axLazyElement directive to lazy load a custom element like '
'. It requires specifying the URL of the element's implementation.
```TypeScript
import { axLazyElement } from '@angular-extensions/elements';
@Component({
selector: 'app-root',
template: '',
standalone: true,
imports: [axLazyElement]
})
export class AppComponent {}
```
--------------------------------
### Lazy Load with Loading and Error Templates
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/docs/api/api.component.html
Shows how to specify custom Angular templates for loading states and error handling when using the `axLazyElement` directive. This allows for a better user experience during the asynchronous loading process.
```HTML
Loading...
Loading failed...
```
--------------------------------
### Configure Lazy Element with Import Maps
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/docs/api/api.component.html
Illustrates how to enable the use of import maps for resolving the element URL by setting the `importMap` input property to `true`. This requires an instance of SystemJS in the application.
```HTML
```
--------------------------------
### Lazy Load Angular Element with axLazyElement Directive
Source: https://github.com/angular-extensions/elements/blob/master/README.md
Demonstrates how to use the `*axLazyElement` directive to lazy load a web component. It shows the necessary imports, schema configuration, and how to bind data and handle events.
```typescript
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { LazyElementDirective } from '@angular-extensions/elements';
@Component({
selector: 'your-org-feature',
imports: [LazyElementDirective],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: '
',
})
export class MyOrgComponent {
elementUrl = 'https://your-org.com/elements/some-element.js';
data: SomeData;
handleChange(change: Partial) {
// ...
}
}
```
--------------------------------
### Lazy Element with Import Maps and SystemJS
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/examples/basic/basic.component.html
Explains how to use the *axLazyElement directive with import maps to load custom elements, requiring SystemJS to be globally available. The 'importMap' flag enables this functionality.
```TypeScript
import { axLazyElement } from '@angular-extensions/elements';
@Component({
selector: 'app-root',
template: '',
standalone: true,
imports: [axLazyElement]
})
export class AppComponent {}
```
--------------------------------
### Pre-configuration with 'isModule' Option
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/examples/advanced/advanced.component.html
Demonstrates pre-configuring the `isModule` flag within the `LazyElementsModule` configuration. This eliminates the need to specify the `isModule` flag in the template for module-style elements.
```typescript
import { NgModule } from '@angular/core';
import { LazyElementsModule, LazyElementConfig } from '@angular/elements';
const elementConfig: LazyElementConfig = {
url: 'https://example.com/elements/module-element.js',
tag: 'module-element',
isModule: true
};
@NgModule({
imports: [
LazyElementsModule.forChild([{ ...elementConfig }])
]
})
```
--------------------------------
### LazyElementsLoaderService Preload Method
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/docs/api/api.component.html
The LazyElementsLoaderService provides a method to preload specified Angular elements or all configured elements. This can improve performance by loading components in advance.
```TypeScript
class LazyElementsLoaderService {
preload(tags?: string[]): void;
}
```
--------------------------------
### Lazy Load Angular Element with URL
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/docs/api/api.component.html
Demonstrates how to use the `axLazyElement` directive to lazy load an Angular element by providing its bundle URL. Supports both inline string values and component property references for the URL.
```HTML
```
--------------------------------
### Lazy Load Angular Element with *axLazyElement
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/docs/how-it-works/how-it-works.component.html
Demonstrates how to use the *axLazyElement directive to lazy load an Angular element. The element is conditionally rendered using `@if`, ensuring that the loading of its bundle is deferred until it's actually needed.
```HTML
```
--------------------------------
### Lazy Element with Loading Template
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/examples/basic/basic.component.html
Shows how to display a loading indicator using an ng-template while a custom element is being lazy loaded. The '#loading' template is shown until the element is ready.
```TypeScript
import { axLazyElement } from '@angular-extensions/elements';
@Component({
selector: 'app-root',
template: '
Loading...
',
standalone: true,
imports: [axLazyElement]
})
export class AppComponent {}
```
--------------------------------
### Dynamically Load Web Components with *axLazyElementDynamic
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/docs/use-cases/use-cases.component.html
The `*axLazyElementDynamic` directive allows for lazy loading of any web component within an Angular application without hard-coding its tag name. This enables dynamic specification of custom element tags at runtime while still supporting standard Angular template property and event bindings.
```TypeScript
import { AXLazyElementDynamicModule } from '@angular-extensions/elements';
@NgModule({
imports: [
// ...
AXLazyElementDynamicModule.forRoot()
]
})
export class AppModule {}
```
--------------------------------
### On-Demand Loading of Heavy Components with *axLazyElement
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/docs/use-cases/use-cases.component.html
The `*axLazyElement` directive facilitates the seamless loading of components on demand, particularly useful for heavy third-party components like rich text editors. This directive ensures that such components are loaded only when they are rendered as a result of user interaction, improving application performance and startup time.
```TypeScript
import { AXLazyElementModule } from '@angular-extensions/elements';
@NgModule({
imports: [
// ...
AXLazyElementModule.forRoot()
]
})
export class AppModule {}
```
--------------------------------
### Dynamically Render Multiple Elements with @for Loop
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/examples/dynamic/dynamic.component.html
Illustrates using the *axLazyElementDynamic directive within an @for loop to render multiple dynamic elements based on a runtime configuration. This is ideal for microfrontend applications where element configurations are fetched from a backend.
```html
@for (c of dynamicConfigs; track c.tag) {
Loading <{{ c.tag }}>...
@if (c.content) {
{{ c.content }}
}
}
```
--------------------------------
### Configure Lazy Element as Module
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/docs/api/api.component.html
Explains how to configure the `axLazyElement` directive to load the element as a module by setting the `module` input property to `true`. This affects the generated script tag with `type="module"`.
```HTML
```
--------------------------------
### ElementConfig Properties for Lazy Loading
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/docs/api/api.component.html
Defines the configuration for individual elements to be loaded lazily. This includes the tag name, URL of the bundle or module, whether to load as a module, import map resolution, custom loading/error components, preloading flags, and lifecycle hooks.
```TypeScript
interface ElementConfig {
tag: string;
url: string;
isModule?: boolean;
importMap?: boolean;
loadingComponent?: Type;
errorComponent?: Type;
preload?: boolean;
hooks?: HooksConfig;
}
```
--------------------------------
### Lazy Elements Registry Interface (TypeScript)
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/docs/api/api.component.html
Defines the contract for custom lazy element registries. It includes methods to manage the loading state (Promises) of element bundles based on their URLs.
```TypeScript
interface LazyElementsRegistry {
get: (url: string) => Promise;
set: (url: string, notifier: Promise) => void;
has: (url: string) => boolean;
}
```
--------------------------------
### Lazy Element with Error Template
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/examples/basic/basic.component.html
Illustrates how to handle loading failures by providing an error template. If the custom element fails to load (e.g., due to an incorrect URL), the '#error' template will be displayed.
```TypeScript
import { axLazyElement } from '@angular-extensions/elements';
@Component({
selector: 'app-root',
template: '
Loading failed...
',
standalone: true,
imports: [axLazyElement]
})
export class AppComponent {}
```
--------------------------------
### LAZY_ELEMENTS_REGISTRY Token for Customization
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/docs/api/api.component.html
A token used to override the default lazy elements registry. This is useful for managing multiple elements or applications on a single page and preventing duplicate downloads of JavaScript bundles. The custom implementation must adhere to the LazyElementsRegistry interface.
```TypeScript
{
provide: LAZY_ELEMENTS_REGISTRY,
useClass: YourRegistryImplementation
}
```
--------------------------------
### Use *axLazyElement Directive in Angular Template
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/home/home.component.html
Apply the `*axLazyElement` directive to an HTML element in your Angular template. Pass the URL of the element bundle to the directive to enable lazy loading.
```html
```
--------------------------------
### Fix RxJs Zone Issue in Angular Elements
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/docs/change-detection/change-detection.component.html
This snippet demonstrates how to import the RxJs zone patch to ensure RxJs streams run in the correct zone within an Angular Element. This is crucial when the element is used within a parent Angular application to prevent change detection failures.
```TypeScript
import 'zone.js/dist/zone-patch-rxjs';
```
--------------------------------
### Import LazyElementDirective in Angular
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/home/home.component.html
Import the `LazyElementDirective` from the `@angular-extensions/elements` package. This directive is essential for enabling the lazy loading functionality.
```typescript
import { LazyElementDirective } from '@angular-extensions/elements';
```
--------------------------------
### Advanced Binding with Lazy Element
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/examples/basic/basic.component.html
Demonstrates passing complex data, like an array, to a lazy-loaded custom element using standard Angular property binding. The 'xAxis' array is passed to the 'xlim' property.
```TypeScript
import { axLazyElement } from '@angular-extensions/elements';
@Component({
selector: 'app-root',
template: '
Loading...
',
standalone: true,
imports: [axLazyElement]
})
export class AppComponent {
xAxis = [-6.28, 6.28];
}
```
--------------------------------
### Configure Angular Component for Lazy Elements
Source: https://github.com/angular-extensions/elements/blob/master/projects/elements-demo/src/app/features/home/home.component.html
Configure your Angular component to use lazy elements by importing `LazyElementDirective` into its `imports` array and adding `CUSTOM_ELEMENTS_SCHEMA` to its `@Component` decorator's `schemas` property.
```typescript
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { LazyElementDirective } from '@angular-extensions/elements';
@Component({
selector: 'my-org-component',
standalone: true,
imports: [LazyElementDirective],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `...`
})
export class MyOrgComponent {}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.