All Projects → ngneat → overview

ngneat / overview

Licence: MIT License
🤖 A collection of tools to make your Angular views more modular, scalable, and maintainable

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
SCSS
7915 projects

Projects that are alternatives of or similar to overview

DuktapeJava
Tiny Powerfull JavaScript Engine On Android Platform integrating with java
Stars: ✭ 74 (-2.63%)
Mutual labels:  dynamic
Splain
small parser to create more interesting language/sentences
Stars: ✭ 15 (-80.26%)
Mutual labels:  dynamic
yii2-dynamic-fields
Widget for display dynamic fields, adding and removing their using Pjax.
Stars: ✭ 52 (-31.58%)
Mutual labels:  dynamic
Dynamic ORB SLAM2
Visual SLAM system that can identify and exclude dynamic objects.
Stars: ✭ 89 (+17.11%)
Mutual labels:  dynamic
Meh
Python configuration files in Python. ¯\_(ツ)_/¯
Stars: ✭ 20 (-73.68%)
Mutual labels:  dynamic
readme-typing-svg
⚡ Dynamically generated, customizable SVG that gives the appearance of typing and deleting text. Typing SVGs can be used as a bio on your Github profile readme or repository.
Stars: ✭ 938 (+1134.21%)
Mutual labels:  dynamic
dynamic-datasource-starter
springboot 动态切换数据的基本思想与实现方法
Stars: ✭ 12 (-84.21%)
Mutual labels:  dynamic
flutter dynamic
The flutter_dynamic is a library that create flutter application dynamic.
Stars: ✭ 66 (-13.16%)
Mutual labels:  dynamic
ImmediateReflection
.NET library that aims to provide faster usage of C# reflection features. Especially the usage of constructor and members accessors (get/set). It also provides an ObjectWrapper object allowing to use Reflection in a faster way. And finally it offers the possibility to create strongly typed delegates.
Stars: ✭ 30 (-60.53%)
Mutual labels:  dynamic
JqueryDataTablesServerSideDemo
Jquery DataTables with Asp.Net Core server side multi column sorting and searching Demo Project.
Stars: ✭ 43 (-43.42%)
Mutual labels:  dynamic
tfvars-annotations
[not-WIP] Update values in terraform.tfvars using annotations
Stars: ✭ 20 (-73.68%)
Mutual labels:  dynamic
anchor
Create Dynamic CLI's as your GitOps Marketplace
Stars: ✭ 38 (-50%)
Mutual labels:  dynamic
django-speedinfo
Django views profiler for small projects
Stars: ✭ 55 (-27.63%)
Mutual labels:  views
Rails-4-ElasticSearch-dynamic-facets
Rails 4 ElasticSearch integration with dynamic facets
Stars: ✭ 16 (-78.95%)
Mutual labels:  dynamic
Dynamic.Programming
C++ codes of Dynamic Programming algorithms
Stars: ✭ 28 (-63.16%)
Mutual labels:  dynamic
CleanUI
Android library to create beautiful, clean and minimal UIs.
Stars: ✭ 19 (-75%)
Mutual labels:  views
ar-dynattribute
Provide ActiveRecord dynamic attributes stored into the single field in serialized state
Stars: ✭ 43 (-43.42%)
Mutual labels:  dynamic
Dynamic-Splitscreen
A simple variation of the commonly used dynamic splitscreen, popularized by the LEGO games.
Stars: ✭ 105 (+38.16%)
Mutual labels:  dynamic
simpleDjangoProject
simpleDjangoProject
Stars: ✭ 30 (-60.53%)
Mutual labels:  views
python-makefun
Dynamically create python functions with a proper signature.
Stars: ✭ 62 (-18.42%)
Mutual labels:  dynamic


npm MIT Commitizen friendly PRs styled with prettier All Contributors ngneat spectator

Overview - The Template for Success in Template Management

Compatibility with Angular Versions

@ngneat/overview Angular
2.x >= 11 < 13
3.x >= 13

Installation

npm i @ngneat/overview
yarn add @ngneat/overview

Table of Contents

DynamicView

Use the dynamicView structural directive to render a component, a template, HTML, or default template dynamically.

Let’s say we build a generic error component. What we want is to give our consumers the flexibly to create it by using one of three options:

  • They can choose to use the default template
  • They can choose to use their own text which can be static or dynamic
  • They can choose to pass their own template or component
import { DynamicViewModule, Content } from '@ngneat/overview';

@Component({
  template: `
    <div *dynamicView="view">
      Default view
    </div>
  `,
})
export class ErrorComponent {
  @Input() view: Content | undefined;
}


@NgModule({
  imports: [DynamicViewModule]
})
class ErrorModule {}

You can also pass a context or an injector as inputs to the directive:

<h5>Component</h5>
<ng-container *dynamicView="component; injector: injector"></ng-container>

<h5>Template</h5>
<ng-template #tpl let-title><b>{{ title }}</b></ng-template>

<ng-container 
     *dynamicView="tpl; 
     context: { $implicit: 'my title' }">
</ng-container>

Teleporting

Teleporting means rendering a view at a different location from its declaration. There are two cases it might be helpful:

  • Avoid prop drilling to a nested component.
  • Rendering a view at another place in the DOM while keeping its context where it’s defined.

You can read more about this approach in this article.

Use the teleportOutlet directive to define a new outlet. An outlet is an anchor where the view will be projected as a sibling.

import { TeleportModule } from '@ngneat/overview';

@Component({ 
  template: `
    <div class="flex">
      <ng-container teleportOutlet="someId"></ng-container>
    </div>
  `
})
export class FooComponent {
}

@NgModule({
  imports: [TeleportModule]
})
export class FooModule {}

Use the teleportTo directive to teleport the view to a specific outlet:

import { TeleportModule } from '@ngneat/overview';

@Component({ 
  template: `
    <section *teleportTo="someId">
      {{ value }}
    </section>
  `
})
export class BarComponent {
  value = '...'
}

@NgModule({
  imports: [TeleportModule]
})
export class BarModule {}

ViewService

The ViewService provides facade methods to create modular views in Angular. It's been used in various projects like hot-toast, and helipopper.

createComponent

The createComponent method takes a Component, and returns an instance of CompRef:

import { ViewService, CompRef } from '@ngneat/overview';

@Injectable()
class ToastService {
  componentRef: CompRef;

  constructor(private viewService: ViewService) {}

  init() {
   this.componentRef = this.viewService
      .createComponent(HotToastContainerComponent)
      .setInput('defaultConfig', defaultConfig)
      .appendTo(document.body);
  }
}

There are cases where we want to use an Angular component template in a third-party library that takes a native DOM element or a string. In this case, we can use the getRawContent or the getElement method, respectively.

import { ViewService } from '@ngneat/overview';

@Directive()
class ChartDirective{

  constructor(private viewService: ViewService) {}

  createChart(color: string) {
   const ref = this.viewService
      .createComponent(FooTooltip)
      .setInput('color', color)
      .detectChanges(document.body);

     const content = ref.getRawContent();

     ref.destroy();

     Highcharts.chart('container', {
      tooltip: {
        formatter: function() {
          return content;
       },
       useHTML: true
     },
   });
  }
}

createComponent Options

createComponent({
  component: Type<C>;
  injector: Injector;
  resolver: ComponentFactoryResolver;
  vcr: ViewContainerRef | undefined;
  appRef: ApplicationRef | undefined;
})

createTemplate

The createTemplate method takes a TemplateRef, and returns an instance of ViewRef.

createTemplate({
  tpl: TemplateRef<C>;
  context: C;
  vcr: ViewContainerRef | undefined;
  appRef: ApplicationRef | undefined;
})

createView

The createView method takes a Component, a TemplateRef or a string, and creates a View:

import { ViewService, Content } from '@ngneat/overview';

@Injectable()
class ToastService {
  constructor(private viewService: ViewService) {}

  createToast(content: Content) {
    const ref = this.viewService.createView(content);
    document.body.appendChild(ref.getElement());
  }
}

Contributors

Thanks goes to these wonderful people (emoji key):


Netanel Basal

💻 🤔

Dharmen Shah

🖋 📖

This project follows the all-contributors specification. Contributions of any kind welcome!

Icons made by Freepik from www.flaticon.com
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].