Opinionated Yeoman generator for AngularJS - lets you quickly generate components that uses ES6 and tries to follow idas from Angular 2 and Web Components
Install generator-ng:
npm install -g Pajn/generator-angular
Available generators:
Generates a directive set up similar to an Angular 2 component in app/components.
Example:
yo ng:component my-componentProduces 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
Generates a directive in app/scripts/directives.
Example:
yo ng:directive myDirectiveProduces 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,
}));Generates a filter in app/scripts/filters.
Example:
yo ng:filter myFilterProduces app/scripts/filters/myFilter.js:
function MyFilter() {
return 'myFilter filter: ' + input;
}
export default angular.module('myFilter', [])
.filter('myFilter', () => MyFilter);Generates an AngularJS service.
Example:
yo ng:service myServiceProduces 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.