Git Product home page Git Product logo

ngx-elements's Introduction

npm version License: MIT

ngx-elements

Wrap and register your Angular Ivy Component as custom element

Getting Started

  • Install dependencies
    git clone https://github.com/aelbore/ngx-elements.git
    cd ngx-elements
    npm install
    

Installation

  npm install ngx-elements

Example

  • npm run ngcc - compile all @angular/* libraries into ivy compatible
  • npm run build - build ngx-elements
  • npm run build:profile - build the example code
  • npm run serve - run into browser http://localhost:5000

API

  • renderCustomElement - wrap and register your component into custom element (web components)
  • renderNgComponent - wrap your component to automatically have change detection

Features

  • Constructable Stylesheets
  • AutoChangeDetectChanges
  • Register Multiple Components, Directives, and Pipes
    renderCustomElement(HelloWorldComponent, {
     directives: [ NgForOf, MyTabItemComponent, MyTabComponent ],
     pipes: [ AsyncPipe ]
    }) 

Usage

  • Create hello-world.ts
    • When you change the value of <input> it will trigger the change detection (detectChanges) to update the <h1> element
    • by default it will trigger the change dectection when any of the properties changed
      import { Component, ViewEncapsulation, Input } from "@angular/core";
      import { renderCustomElement } from 'ngx-elements'
      
      @Component({
        selector: "hello-world",
        template: `
          <h1>Hello {{ name }}</h1>
          <input 
            [value]="name" 
            (input)="updateName($event.target.value)" 
           />
        `,
        styles: [`
          h1 { 
           color: var(--h1-color, blue) 
          }
        `],
        encapsulation: ViewEncapsulation.ShadowDom
      })
      export class HelloWorldComponent {
        
        @Input() name: string = "World"
      
        updateName(newName: string) {
          this.name = newName
        }
      
      }
      
      renderCustomElement(HelloWorldComponent)

ngx-elements's People

Contributors

aelbore avatar gilsdav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

zah33r gilsdav

ngx-elements's Issues

Rollup issue: Generated an empty chunk

Hello, this project looks promising, however when I try to build the example I get an empty chunk without any js code in it:

npm run build:hello:world

> [email protected] build:hello:world
> rollup -c ./examples/hello-world/rollup.config.js


./examples/hello-world/src/hello-world.ts → ./public/hello-world...
┌──────────────────────────────────┐
│                                  │
│   Bundle Name:  hello-world.js   │
│   Bundle Size:  1 B              │
│   Minified Size:  0 B            │
│   Gzipped Size:  20 B            │
│                                  │
└──────────────────────────────────┘
(!) Generated an empty chunk
hello-world
created ./public/hello-world in 1.5s

And my hello-word.js file is just empty:


//# sourceMappingURL=hello-world.js.map

I also tried with the examples in your rollup-plugin-ngc repository and got the same issue... any idea what's causing this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.