ng2gen 0.3.0

  • Readme
  • Changelog
  • Installing
  • 0

ng2gen #

This is an Angular2 Component File Generator

Installation #

To install this package globally you only need to do:

pub global activate ng2gen

this will download and install ng2gen executable into ~/.pub-cache/bin, then add ~/.pub-cache/bin to your path to directly use the executable like this

ng2gen new app

or you can use

pub global run ng2gen:new app

Usage #

  • ng2gen new my_app
  • ng2gen component my_component
  • ng2gen component_inline my_component
  • ng2gen directive my_directive
  • ng2gen service my_service
  • ng2gen pipe my_pipe
  • ng2gen route home /home_path
  • ng2gen init

Create an Application #

mkdir my_app && cd $_ #create directory where the app is going to live
ng2gen new my_app

This will create an Angular2 application in the folder my_app.

Use the generated app #

grind serve to start your application.

The application comes with grind to help you in your development. - serve - build - test - doc - deploy

Create Component #

To create a component you only need to do this:

ng2gen component my_component

It will generate a component in your current directory. this should generate next files structure:

  └─ my_component
       ├─ my_component.dart
       ├─ my_component.css
       └─ my_component.html

If you execute this command inside an application generated by ng2gen, the component will be automatically include to your application under the path specified inside the angular.config.yaml file.

Create Component with Inline Template #

To create a component with inline template you only need to do this:

ng2gen component_inline my_component

This command wont generate an html template, the html will be in the my_component.dart file.

Create Directive #

To create a directive you only need to do this:

ng2gen directive my_directive

This should generate my_directive.dart.

Create Service #

To create a service you only need to do this:

ng2gen directive my_service

This should generate my_service.dart.

Create Pipe #

To create a pipe you only need to do this:

ng2gen pipe my_pipe

This should generate my_pipe.dart.

Create Route #

To create a route you only need to do this:

ng2gen route home /home_path

This should generate :

       ├─ home_route_component.dart
       ├─ home_route_component.css
       └─ home_route_component.html

0.3.0 #

  • remove app generator
  • upgrade to angular 4

0.2.1+1 #

  • small fix on service generation

0.2.1 #

  • specify file extension in config file:
    • css_extension: css
    • html_extension: html

0.2.0 #

  • Add init command to create a config file inside an existing project
  • Update Angular2
  • move all libraries export to lib/
  • simplify generated file name (no '_component.dart', '_service.dart'...)
  • sass support
  • less support
  • refactor Route defintion

0.1.0 #

  • Add full application generation with new command
  • config file generator.config.yaml, the config file determine where to create components, directives, services...
  • include grind task (build, serve, deploy ...)
  • Add pipe generator
  • Update previous generators to be able to use them from root app folder

pre-0.1.0 #

  • component generator
  • component_inline generator
  • service generator
  • directive generator

Use this package as an executable

1. Install it

You can install the package from the command line:

$ pub global activate ng2gen

2. Use it

The package has the following executables:

$ ng2gen

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  ng2gen: ^0.3.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:ng2gen/ng2gen_configs.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0