npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-dynamic-hooks

v3.1.1

Published

Automatically insert live Angular components into a dynamic string of content (based on their selector or any pattern of your choice) and render the result in the DOM.

Downloads

17,072

Readme

Angular Dynamic Hooks

GitHub Actions Workflow Status Coverage NPM License Static Badge

Angular Dynamic Hooks allows you to load Angular components into dynamic content, such as HTML strings (similar to a "dynamic" template) or even already-existing HTML structures.

Works as part of an Angular app or fully standalone. Load components by selectors or any text pattern. No JiT-compiler required - just install and go.

A short animated gif showing how to use the Angular Dynamic Hooks library to load components

Installation

Simply install via npm (or yarn)

npm install ngx-dynamic-hooks

Compatibility

| Angular | Version | NPM | | --- | --- | --- | | 6 - 12 | 1.x.x | ngx-dynamic-hooks@^1 | | 13-16 | 2.x.x | ngx-dynamic-hooks@^2 | | 17+ | 3.x.x | ngx-dynamic-hooks@^3 |

As the library does not rely on a runtime compiler, it works in both JiT- and AoT-environments.

Upgrading to v3: If you have been using v2 of the library and are looking to upgrade, have a look at Version 3 - What's new? for a list of breaking changes.

Quickstart

Import the DynamicHooksComponent as well as your dynamic component(s) to load:

import { Component } from '@angular/core';
import { DynamicHooksComponent } from 'ngx-dynamic-hooks';
import { ExampleComponent } from 'somewhere';

@Component({
  ...
  imports: [DynamicHooksComponent]
})
export class AppComponent {
  // The content to parse
  content = 'Load a component here: <app-example></app-example>';
  // A list of components to look for
  parsers = [ExampleComponent];
}

Then just use <ngx-dynamic-hooks> where you want to render the content:

<ngx-dynamic-hooks [content]="content" [parsers]="components"></ngx-dynamic-hooks>

That's it! If <app-example> is the selector of ExampleComponent, it will automatically be loaded in its place, just like in a normal template.

Documentation

Please note that the above is a very minimal example and that there are plenty more features and options available to you. Check out the docs to find out how to tailor the library to your exact needs. Highlights include:

  • ⭐ Loads fully-functional Angular components into dynamic content
  • 📖 Parses both strings and HTML trees to load components into them like a template
  • 🚀 Can be used fully standalone (load components into HTML without Angular)
  • 🏃 Works without needing the JiT compiler
  • 💻 Works with Server-Side-Rendering
  • 🔍 Loads components by their selectors, custom selectors or any text pattern of your choice
  • ⚙️ Services, Inputs/Outputs, Lifecycle Methods and other standard features all work normally
  • 💤 Allows lazy-loading components only if they appear in the content
  • 🔒 Can pass custom data safely to your components via an optional context object

Donate

If you like the the library and would like to support the ongoing development, maintenance and free technical support, you can consider making a small donation. Your help is greatly appreciated - Thank you!

Issues

Please post bugs or any bigger or smaller questions you might have in the issues tab and I will have a look at them as soon as possible.