All Projects → seeden → Angular Es6

seeden / Angular Es6

Licence: mit
Angular ES6 utility library. Write directives, controllers and services as ES6 classes.

Programming Languages

javascript
184084 projects - #8 most used programming language
es6
455 projects

Projects that are alternatives of or similar to Angular Es6

Threejs Es6 Webpack Starter
Three.js ES6 starter project with a sane webpack configuration
Stars: ✭ 85 (-17.48%)
Mutual labels:  webpack, babel
Award
⚙基于react的服务端渲染框架
Stars: ✭ 91 (-11.65%)
Mutual labels:  webpack, babel
Compiled
A familiar and performant compile time CSS-in-JS library for React.
Stars: ✭ 1,235 (+1099.03%)
Mutual labels:  webpack, babel
Frontie Webpack
Front-end Boilerplate | Gulp 4 + Webpack 4 + Babel + ITCSS Architecture + BEM Methodology + Twig.js
Stars: ✭ 102 (-0.97%)
Mutual labels:  webpack, babel
Wordless
All the power of Pug, Sass, Coffeescript and WebPack in your WordPress theme. Stop writing themes like it's 1998.
Stars: ✭ 1,374 (+1233.98%)
Mutual labels:  webpack, babel
Tkframework
react + relay + redux + saga + graphql + webpack
Stars: ✭ 83 (-19.42%)
Mutual labels:  webpack, babel
React Boilerplate
This project is deprecated. Please use CRA instead.
Stars: ✭ 88 (-14.56%)
Mutual labels:  webpack, babel
Eleventy Webpack
A barebone Eleventy and Webpack boilerplate 🎈
Stars: ✭ 68 (-33.98%)
Mutual labels:  webpack, babel
Koa Mobx React Starter
A straightforward starter for Node javascript web projects. Using Koa, MobX and ReactJS (with universal / isomorphic server rendering)
Stars: ✭ 102 (-0.97%)
Mutual labels:  webpack, babel
Webpack Core Usage
webpack2完整系列课程,欢迎阅读。同时欢迎移步我的react全家桶文章全集: https://github.com/liangklfangl/react-article-bucket
Stars: ✭ 94 (-8.74%)
Mutual labels:  webpack, babel
Hactar
The solution to JavaScript Fatigue. Zero config dev
Stars: ✭ 82 (-20.39%)
Mutual labels:  webpack, babel
React From Scratch
Building a Modern React App from Scratch in 2021
Stars: ✭ 87 (-15.53%)
Mutual labels:  webpack, babel
Spa Starter Kit
📦 Quick starter kit for booting up a NodeJS container with React, webpack, babel/ES2015, Redux, and more.
Stars: ✭ 81 (-21.36%)
Mutual labels:  webpack, babel
Esbuild Loader
⚡️ Speed up your Webpack build with esbuild
Stars: ✭ 1,245 (+1108.74%)
Mutual labels:  webpack, babel
Mostly
They mostly come at night; mostly.
Stars: ✭ 78 (-24.27%)
Mutual labels:  webpack, babel
Cookiecutter Webpack
Boilerplate for webpack 2, babel, react + redux + hmr, and karma. Can be inserted into existing django projects.
Stars: ✭ 87 (-15.53%)
Mutual labels:  webpack, babel
Starter React Flux
Generate your React PWA project with TypeScript or JavaScript
Stars: ✭ 65 (-36.89%)
Mutual labels:  webpack, babel
Vue Web Extension
🛠️ A Vue CLI 3+ preset (previously a Vue CLI 2 boilerplate) for quickly starting a web extension with Vue, Babel, ESLint and more!
Stars: ✭ 1,147 (+1013.59%)
Mutual labels:  webpack, babel
Awesome Coding Javascript
📌 持续构建个人的源码库(JavaScript 原生、常用库、数据结构、算法)
Stars: ✭ 88 (-14.56%)
Mutual labels:  webpack, babel
Nodefony Starter
Nodefony Starter Node.js Framework
Stars: ✭ 95 (-7.77%)
Mutual labels:  webpack, babel

Angular ES6 utility library. Write directives, controllers and services as ES6 classes.

What you will get

  • Write directives, controllers and services like an ES6 classes
  • Autoload directives, controllers, services, filters and factories with webpack

Babel

Use version 2.x for the babel 5 and version 3.x for the babel 6

Instalation

npm install angular-es6

Examples

You can find whole example project in the example directory.

Directive

export default class NiceDirective {
  static $inject = ['$http'];

  constructor($http) {
    this.$http = $http;

    this.template = '<div>{{computeName('NICE')}}</div>';
    this.restrict = 'E';
    this.scope = {
      name: '=',
    };
  }

  link(scope) {
    this.scope = scope;
    scope.computeName = (suffix) => this.computeName(suffix);
  }

  computeName(suffix = '') {
    const { $http, scope } = this;

    return 'Mr.' + scope.name + ' ' +  suffix;
  }
}

Controller

export default class MainController {
  static $inject = ['$scope', '$http'];

  constructor($scope, $http) {
    this.$http = $http;

    $scope.doThis = () => this.doThis();
  }

  doThis() {
    const { $http } = this;
    ...
  }
}

Class Inject

As you can see in the examples above. You need to store injected objects somehow. There is a better solution. You can extend your class with class named Inject and then you can use variable named this.$inject.

In next example is called function doThis from the constructor. You can use this.$inject because this object was initialized by Inject constructor.

Do not forget to use (...args). Inject class need to get all injected objects.

import { Inject } from 'angular-es6';

export default class MainController extends Inject {
  static $inject = ['$http'];

  constructor(...args) {
    super(...args);

    this.doThis();
  }

  doThis() {
    const { $http } = this.$inject;
  }
}

Directive auto Inject

You can use variables from the link function anywhere in your directive code. This feature is available without extending Inject class. Here is small example

export default class NiceDirective {
  static $inject = ['$http'];

  constructor($http) {
    this.$http = $http;

    this.template = '<div>{{computeName('NICE')}}</div>';
    this.restrict = 'E';
    this.scope = {
      name: '=',
    };
  }

  link(scope) {
    scope.computeName = (suffix) => this.computeName(suffix);
  }

  computeName(suffix = '') {
    const { scope, element } = this.link.$inject;

    element.text('Mr.' + scope.name + ' ' +  suffix);
  }
}

Auto load directives

Each directory need to have file index.js with content like this:

import { load } from 'angular-es6';
const MODULE_NAME = 'myProject.directives';

load.directives(require.context('./', true, /.*\.js$/), MODULE_NAME);
export default MODULE_NAME;

More examples you can find in the example directory.

Pull request

Pull requests are welcome

Run build for production

npm run build

Run build for development

npm run dev
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].