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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngadapter

v1.2.1

Published

Wrapper around ngUpgrade to extend the support to attribute directives

Downloads

12

Readme

npm version Build Status Test Coverage

AngularJS and Angular2 Adapter

This adapter extends the angular2 UpgradeAdapter by support for attribute directives. The usage is similar to the standard UpgradeAdapter.

Setup

import {ngAdapter} from 'ngAdapter/build/ngAdapter';

//create your AngularJS module
let module = angular.module('MyApp', []);

//create adapter
let adapter = new ngAdapter(module);

/**
 * modify your module
 */

adapter.bootstrap(document.body, ['MyApp']);

Downgrade Functions

// downgrade Component & Directive
module.directive('myNg2Component', adapter.downgradeNg2Component(MyNg2Component));
module.directive('myNg2Directive', adapter.downgradeNg2Directive(MyNg2Directive));

//downgrade NgModule
@NgModule({})
class MyNg2Module {}
adapter.addNg2Module(MyNg2Module);
let moduleName = adapter.downgradeNg2Module(MyNg2Module); //'MyNg2Module'
angular.module('App').requires.push(moduleName);

//downgrade Service
module.factory('myNg2Service', adapter.downgradeNg2Provider(MyNg2Service));

Upgrade Functions

upgradeAdapter.upgradeNg1Provider('myNg1Service');

@Component({
    selector: 'my-ng2-component',
    template: `
      <span my-ng1-attribute-directive>Hello World</span>
      <my-ng1-directive></my-ng1-directive>
    `
})
export class AppComponent {
  constructor(@Inject('myNg1Service') service: MyNg1Service) {}
}

@NgModule({
  directives: [
    adapter.upgradeNg1Directive('myNg1AttributeDirective'),
    adapter.upgradeNg1Component('myNg1Directive'),
    AppComponent
  ]
})
class MyNg1Module {}

Angular 2 usage

//add an Angular 2 Module to the hybrid app via addNg2Module
@NgModule({
  providers: [MyNg2Service]
})
class MyNg2Module {}
adapter.addNg2Module(MyNg2Module);

//add an Angular 2 service to the Angular 2 root injector
@Injectable()
class MyService {}
adapter.addProvider(MyService);