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

angular-es

v1.0.1

Published

Angular 1.x ES helper

Downloads

52

Readme

Build Status Coverage Status npm version Downloads

angular-es

This is a helper library for developing [email protected] applications with ES7 decorators.

Benefits

  • Perfectly runs with jspm, webpack & babel
  • Supports lazy loading & initialization with libraries like $ocLazyLoad
  • Perfectly suits for folder-by-feature application structure
  • Simple in usage

Installation

npm install angular-es

Available decorators

Usage

Component

Define component

import {Component, Module, Inject} from 'angular-es';

@Module('my.module')
@Component({
	selector: 'my-component',
	bindings: {
		data: '='
	},
	template: `<p>{{ $ctrl.data }}</p>`
})
@Inject('myService')
class MyComponentController {

	myService;
	
	constructor(myService) {
		this.myService = myService;
	}
}

Config

Add config block

import {Config, Module, Inject} from 'angular-es';

@Module('my.module')
@Config
@Inject('$myServiceProvider')
class MyModuleConfig {
	
	constructor($myServiceProvider) {
	}
}

Constant

Register constant

import {Constant, Module} from 'angular-es';

@Module('my.module')
@Constant('MY_CONSTANT')
class MyConstant {
	foo = 'foo';
	bar = 'bar';
}

Controller

Register controller

import {Controller, Module, Inject} from 'angular-es';

@Module('my.module')
@Controller('MyController')
@Inject('$myService')
class MyController {
	
	$myService;
	
	constructor($myService) {
		this.$myService = $myService;
	}
}

Decorator

Provide decorator

import {Decorator, Module, Inject} from 'angular-es';

@Module('my.module')
@Decorator('$http')
@Inject('$delegate')
class HttpDecorator {
	constructor($delegate) {
		$delegate.decorated = true;

		return $delegate;
	}
}

export {HttpDecorator};

Directive

Register directive

import {Directive, Module, Inject} from 'angular-es';

@Module('my.module')
@Directive('my-directive')
@Inject('$myService')
class MyDirective {
	
	$myService;
	
	restrict = 'A';
	controllerAs = 'vm';
	
	constructor($myService) {
		this.$myService = $myService;
	}
	
	@Inject('$scope')
	controller($scope) {
	}
	
	link(scope) {
		this.$myService;
	}
}

Factory

Register factory

import {Factory, Module, Inject} from 'angular-es';

class TestModel {
	static $q;
	static myService
}

@Module('my.module')
@Factory('TestModel')
@Inject('$q', 'myService')
class TestModelFactory {
	constructor($q, myService) {
		TestModel.$q = $q;
		TestModel.myService = myService;
		return TestModel;
	}
}

Filter

Register filter

import {Module, Filter, Inject} from 'angular-es';

@Module('my.module')
@Filter('test')
@Inject('$q')
class TestFilter {

	$q;

	constructor($q) {
		this.$q = $q;
		return ::this.filter;
	}

	filter(input) {
		const $q = this.$q;
		return input.toUpperCase();
	}
}

Inject

Adds $inject to target

import {Inject} from 'angular-es';

@Inject('$rootScope')
class BaseInjectedClass {
}

@Inject('$http', '$q')
class InjectedClass extends BaseInjectedClass {

    constructor($rootScope, $http, $q) {
    	super($rootScope);
    }

	@Inject('$q')
	injectedMethod() {
	}

	@Inject('$q')
	static injectedMethod() {
	}
}

InjectAsProperty

Injects provided dependencies as properties

import {Module, Service, InjectAsProperty} from 'angular-es';

@Module(test.name)
@Service('testService')
@InjectAsProperty('$q', '$http')
class TestService {
	testMethod() {
		return this.$http();
	}
}

Module

Attaches target to specified angular module @Module decorator is required and it has to be present at the top level of target annotation block Make sure that used angular module is already available

import {Module, Controller} from 'angular-es';
import my from './my.module';

@Module(my.name)
@Controller('MyController')
class MyController {
}

Provider

Register provider

import {Provider, Module, Inject} from 'angular-es';

@Module('my.module')
@Provider('myService')
class MyServiceProvider {

	static config;

	config(config) {
		MyServiceProvider.config = config;
	}

	@Inject('$q')
	$get($q) {
		return {
			getConfig: getConfig
		};

		function getConfig() {
			return $q.resolve(MyServiceProvider.config);
		}
	}
}

Run

Add run block

import {Run, Module, Inject} from 'angular-es';

@Module('my.module')
@Run
@Inject('$rootScope')
class MyRunBlock {
	
	constructor($rootScope) {
	}
}

Service

Register service

import {Service, Module, Inject} from 'angular-es';

@Module('my.module')
@Service('MyService')
@Inject('$http')
class MyService {
	
	$http;
	
	constructor($http) {
		this.$http = $http;
	}
}

Value

Register value

import {Value, Module} from 'angular-es';

@Module('my.module')
@Value('myValue')
class MyValue {
	foo = 'foo';
	bar = 'bar';
}