1.3.0 • Public • Published


An angular module that provides a plugin registry system for arbitrarily injecting additional UI components into views. A primary use case would be allowing developers to add components to an application without compiling the extension point files into the actual application.


Include the minified script in your html file. If you want to use the pre-compiled default templates, include the additional template script.

<script src="/path/to/angular-extension-registry/dist/angular-extension-registry.min.js"></script>
<script src="/path/to/angular-extension-registry/dist/compiled-templates.js"></script>

Then require the module in your app. This is done in the typical Angular fashion:

// require 'extension-registry'
angular.module('myapp', [

View Output

Output points must be defined in the views like this:

  - extension-point is the main directive
  - configure it with extension-name="space delimited endpoint names"
  - configure it with extension-types to filter out types of objects it will
    render.  objects that do not match this filter will not be rendered.
  - configure runtime contextual data via extension-args.  This object will be
    passed to each registered callback function to generate unique output
  - in certain cases the # of items may need to be limited.  use extension-limit
  extension-name="register1 register2"
  extension-types="text link select html"

Data Input

Then the service can be used to register data objects for render. Two-way data binding will apply, output will re-render whenever the UI changes:

Built in types

Currently, there are 4 built-in extension types. Some quick vanilla examples:

// type: text
  type: 'text',
  className: 'my-text',
  text: 'This is some text.'
// type: link
  type: 'link',
  className: 'my-class',
  linkText: 'google link',
  href: '',
  target: '_blank'
// link: with an onclick function
  type: 'link',
  className: 'my-class'
  linkText: 'google alert',
  onClick: function() {
// type: select box
  type: 'select',
  className: 'i am a select box test',
  nameText: 'select-name',
  options: [
      label: 'bar 1 - 1',
      value: 'bar'
      label: 'bar 1 - 2',
      value: 'thing'
      label: 'bar 1 - 3',
      value: 'other'
  onChange: function(item) {
    console.log('selected', item);
// type: dom
// NOTE: node: '' can be a jQuery object, or a plain string
  type: 'dom',
  node: '<div>Hello World</div>'
// or
  type: 'dom',
  node: $('<div>')
          .text('Hello world')
// and can be as complex as desired:
  type: 'dom',
  // arbitrary keys can be added to the object, these will be
  // accessible via node once rendered
  url: '',
  onClick: function() {
    $, '_blank');
  node: [
    '<div row ',
      'ng-show="item.url" ',
      'class="foo" ',
      'title="A link title">',
          '<i class="fa fa-share" aria-hidden="true"></i>',
          '<a ng-click="item.onClick($event)" ',
            'Open some link',

Adding custom types

To add a new type, you must name the type & provide a template for rendering. Templates are given a model object called item.

Example of adding a new type:

extensionRegistry.addType('li', '<li>{{item.text}}</li>');

This will register the template with angular's $templateCache for use whenever the extension point is needed. Templates are registered as __extension-<type-name>.html.

Other return types

A registered callback function can return any of the following:

  • inapplicable, undefined
  • simple, object
  • simple, array
  • complex, promise

A function that returns nothing may be used to instead manipulate the data. It is encouraged to be a good citizen, of course. Changing data that will be used by other registered extensions could have undesirable consequences.

Data registration

Registering the data objects to a specific endpoint happens via a registration function. The function will receive contextual arguments and can return a promise, data, etc.

// args is an object set via the directive in the view.
// likely it is some object on a controller scope that gives
// meaning to the endpoint.
extensionRegistry.add('endpoint1', function(args) {
  return $q.when([
    // my objects

A typical registration example:

    function($q, $timeout, extensionRegistry) {
      // args is provided via the directive attrib extension-args="some_object"
      // and can be used to customize the data objects that will be rendered
      extensionRegistry.add('register1', function(args) {
        // simulate async (service calls, etc)
        return $q.when([
          // add a single link, assuming the args to the directive will provide
          // a name & href for the object
            type: 'link',
            href: args.href,
            displayName: + ' link',
            target: '_blank'
      // multiple items registered
      extensionRegistry.add('register1', function(args) {
        return $q.when([
            type: 'link',
            href: args.href,
            displayName: + ' link',
            target: '_blank'
            type: 'link',
            displayName: + 'alert',
            onClick: function() {

It is perfectly fine to register endpoints ahead of time, then later register additional callbacks. Example:

// then elsewhere:
extensionRegistry.add('foo', function(args) {
  // do stuff...

It is fine to register multiple callbacks to an endpoint:

extensionRegistry.add('endpoint1', function() {  return [ /* stuff */ ] });
extensionRegistry.add('endpoint1', function() {  return [ /* stuff2 */ ] });
extensionRegistry.add('endpoint1', function() {  return [ /* stuff3 */ ] });
extensionRegistry.add('endpoint1', function() {  return [ /* stuff4 */ ] });

Deregistering data

Each time you register data to a registry, the .add() function will return an object that has a .remove() function bound to that particular data set, allowing you to unregister that block of data. Calling .remove() does not clear an entire registry, ONLY the data that was registered in that data set.

var reg = extensionRegistry.add('endpoint1', function() {  return [ /* stuff */ ] });
// nah, actually we don't want this anymore.

Template usage / overrides

The /src/views/ directory houses the source html files used to generate templates. These are compiled into /dist/compiled-templates.js. The script can be included to use the default templates, or you can create your own overrides by making templates that match the template path name. Example: __extension-link.html.

These templates will need to be registered via Angular's templateCache. The best way to do this is with a build tool, such as gulp's gulp-angular-templatecache plugin.

View the demos

Clone the project, then run the following from the root directory:

npm install bower install gulp serve

This will load a file in your browser with links to the /demos directory. Feel free to experiment with these examples.




Package Sidebar


npm i angular-extension-registry

Weekly Downloads






Unpacked Size

112 kB

Total Files


Last publish


  • spadgett