Skip to content

Pajn/generator-angular

 
 

Repository files navigation

AngularJS generator

Opinionated Yeoman generator for AngularJS - lets you quickly generate components that uses ES6 and tries to follow idas from Angular 2 and Web Components

Usage

Install generator-ng:

npm install -g Pajn/generator-angular

Generators

Available generators:

Component

Generates a directive set up similar to an Angular 2 component in app/components.

Example:

yo ng:component my-component

Produces app/components/my-component/my-component.js:

class MyComponent {
	constructor() {}
}

export default angular.module('myComponent', [])
	.directive('myComponent', () => ({
    templateUrl: 'components/my-component/my-component.html',
    restrict: 'E',
    scope: {
      // Specify attributes where parents can pass and receive data here
      // Syntax name: 'FLAG'
      // FLAGS:
      // = Two way data binding
      // @ One way incoming expression (like placeholder)
      // & One way outgoing behaviour (like ng-click)
    },
    bindToController: true,
    controller: MyComponent ,
    controllerAs: 'ctrl',
	}));

Also produces

app/components/my-component/my-component.html
app/components/my-component/my-component.scss

Directive

Generates a directive in app/scripts/directives.

Example:

yo ng:directive myDirective

Produces app/scripts/directives/myDirective.js:

function MyDirective(scope, element, attrs) {
  element.text('this is the myDirective directive');
}

export default angular.module('myDirective', [])
  .directive('myDirective', () => ({
    restrict: 'A',
    link: MyDirective,
  }));

Filter

Generates a filter in app/scripts/filters.

Example:

yo ng:filter myFilter

Produces app/scripts/filters/myFilter.js:

function MyFilter() {
  return 'myFilter filter: ' + input;
}

export default angular.module('myFilter', [])
  .filter('myFilter', () => MyFilter);

Service

Generates an AngularJS service.

Example:

yo ng:service myService

Produces app/scripts/services/myService.js:

class MyService {
	constructor() {}
}

export default angular.module('myService', [])
	.service('myService', MyService);

You can also do yo ng:value, and yo ng:constant for other types of services.

License

BSD license

About

Yeoman generator for AngularJS

Resources

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 59.9%
  • ApacheConf 28.2%
  • HTML 8.4%
  • CSS 3.5%