ProductPromotion
Logo

Angular.JS

made by https://0x3d.site

GitHub - taiga-family/ng-polymorpheus: Polymorpheus is a tiny library for polymorphic templates in Angular.
Polymorpheus is a tiny library for polymorphic templates in Angular. - taiga-family/ng-polymorpheus
Visit Site

GitHub - taiga-family/ng-polymorpheus: Polymorpheus is a tiny library for polymorphic templates in Angular.

GitHub - taiga-family/ng-polymorpheus: Polymorpheus is a tiny library for polymorphic templates in Angular.

Polymorpheus

npm version Coverage Status angular-open-source-starter telegram chat

Polymorpheus is a tiny library for polymorphic templates in Angular.

It is 1 KB gzip, dependency free and allows you to make pretty cool things.

Polymorpheus

What does it do?

It abstracts over different ways of view customization in Angular with one simple structural directive:

<ng-container *polymorpheusOutlet="content as text; context: context">{{text}}</ng-container>

Content accepts:

  • primitives like number or string
  • functions that take context as argument and return a primitive
  • templates that get instantiated with given context
  • components that would get context injected through DI

Context is optional when you need your content to adapt to the situation

How to use it?

Typical use case would be a component that accepts visual customization and defines context by itself. Say a menu list where you can configure how each item should look like by passing a template. And context would be item itself and, for example, whether it is focused or not.

Please see extensive demo (wait for packages to install and run npm start).

You can also read about this concept in detail.

Accessing context in dynamic component

If you use component content you can inject context with POLYMORPHEUS_CONTEXT token.

Important! This object is live so if you change it, your component will not be recreated:

@Component({
  template: `
    {{ context.active }}
  `, // <-- this will automatically update
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MyComponent {
  constructor(@Inject(POLYMORPHEUS_CONTEXT) readonly context: {active: boolean}) {}
}

Adding type to template context

You can use polymorpehus directive to add type to template context:

readonly context!: { $implicit: number };
<ng-template
  #template="polymorpheus"
  [polymorpheus]="context"
  let-item
>
  {{ item.toFixed(2) }} <-- type 'number'
</ng-template>

Core team

ng-polymorpheus is a part of Taiga UI libraries family which is backed and used by a large enterprise. This means you can rely on timely support and continuous development.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory