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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ng-custom-element

v2.0.3

Published

<h1 align="center">ng-custom-element</h1>

Readme

Background

Custom elements are great. Angular Elements is a great way of making custom elements from Angular code. Angular Elements is therefore also a great upgrade strategy for AngularJS apps looking to upgrade to Angular.

In AngularJS 1.7.3, some helpers were introduced for binding properties and events to custom elements from surrounding AngularJS code.

For example:

angular.module('app', ['']).controller('ExampleController', function() {
  this.controllerProp = {
    somObj: 'val'
  };
  this.onClick = function clickHandler($event) {
    console.log('was clicked', $event);
  };
});
<my-element ng-prop-my_prop="$ctrl.controllerProp" ng-on-click="$ctrl.onClick($event)"></my-element>

ng-prop-* and ng-on-* are awesome, but not backwards compatible

The changes introduced to facilitate the helpers for ng-prop-* and ng-on-* are not backwards compatible. This library therefore exposes a custom directive called ng-custom-element which allows you to emulate how it works!

It has been tested in AngularJS versions as far back as 1.3, but it may even work in versions older than that.

Assuming the exact controller code from above, let's compare the HTML from the AngularJS 1.7.3+ helpers and this library:

AngularJS 1.7.3+

<my-element ng-prop-my_prop="$ctrl.controllerProp" ng-on-click="$ctrl.onClick($event)"></my-element>

ng-custom-element (AngularJS 1.3+)

<my-element ng-custom-element ngce-prop-my_prop="$ctrl.controllerProp" ngce-on-click="$ctrl.onClick($event)"></my-element>

Pretty sweet!

Usage

  1. Install the library and add its angular.module as a dependency of your own:
angular.module('yourAwesomeApp', ['ngCustomElement']);
  1. Apply the attribute directive ng-custom-element to any DOM element you want to bind properties or events to
<my-element ng-custom-element></my-element>
  1. Use ngce-prop-* to bind properties (see the notes on casing below) to the element:
<my-element ng-custom-element ngce-prop-my_prop="someAngularJSControllerProp"></my-element>
  1. Use ngce-event-* to bind events (see the notes on casing below) to the element:
<my-element ng-custom-element ngce-on-click="someAngularJSControllerMethod($event)"></my-element>

Notes on casing

We need to pay special attention to casing.

From the ngProp docs: https://docs.angularjs.org/api/ng/directive/ngProp

Since HTML attributes are case-insensitive, camelCase properties like innerHTML must be escaped. AngularJS uses the underscore (_) in front of a character to indicate that it is uppercase, so innerHTML must be written as ng-prop-inner_h_t_m_l="expression" (Note that this is just an example, and for binding HTML ngBindHtml should be used).

From the ngOn docs: https://docs.angularjs.org/api/ng/directive/ngOn

Since HTML attributes are case-insensitive, camelCase properties like myEvent must be escaped. AngularJS uses the underscore (_) in front of a character to indicate that it is uppercase, so myEvent must be written as ng-on-my_event="expression".