ng2gen 0.3.0

  • Installing
  • Versions
  • 49


This is an Angular2 Component File Generator


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


  • 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


  • remove app generator
  • upgrade to angular 4


  • small fix on service generation


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


  • 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


  • 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


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

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

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or packages 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';
Version Uploaded Documentation Archive
0.3.0 Sep 7, 2017 Go to the documentation of ng2gen 0.3.0 Download ng2gen 0.3.0 archive
0.2.1+1 Jan 11, 2017 Go to the documentation of ng2gen 0.2.1+1 Download ng2gen 0.2.1+1 archive
0.2.1 Nov 12, 2016 Go to the documentation of ng2gen 0.2.1 Download ng2gen 0.2.1 archive
0.2.0 Oct 25, 2016 Go to the documentation of ng2gen 0.2.0 Download ng2gen 0.2.0 archive
0.1.0 May 28, 2016 Go to the documentation of ng2gen 0.1.0 Download ng2gen 0.1.0 archive
0.0.3 Jan 30, 2016 Go to the documentation of ng2gen 0.0.3 Download ng2gen 0.0.3 archive
0.0.2 Jan 30, 2016 Go to the documentation of ng2gen 0.0.2 Download ng2gen 0.0.2 archive
0.0.1+1 Jan 30, 2016 Go to the documentation of ng2gen 0.0.1+1 Download ng2gen 0.0.1+1 archive
0.0.1 Jan 30, 2016 Go to the documentation of ng2gen 0.0.1 Download ng2gen 0.0.1 archive


We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
97 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, other

Platform components identified in package: io.


  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use ng2gen.dart.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Run dartfmt to format lib/ng2gen_configs.dart.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0
dart_style ^0.2.2 0.2.16 1.0.10
dev_string_converter ^0.1.0 0.1.0 0.2.0
resource ^1.1.0 1.1.0 2.1.2
stagehand ^1.0.8 1.1.8 1.1.9
yaml ^2.1.9 2.1.13
yamlicious ^0.0.4 0.0.5
Transitive dependencies
analyzer 0.29.11 0.31.1
args 0.13.7 1.4.2
async 2.0.6
charcode 1.1.1
cli_util 0.0.1+2 0.1.2+1
collection 1.14.9
convert 2.0.1
crypto 2.0.2+1
csslib 0.14.1
glob 1.1.5
html 0.13.3
http 0.11.3+16
http_parser 3.1.1
isolate 1.1.0 2.0.0
logging 0.11.3+1
meta 1.1.2
package_config 1.0.3
path 1.5.1
plugin 0.2.0+2
quiver_iterables 1.0.1
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
usage 3.4.0
utf 0.9.0+4
watcher 0.9.7+7
when 0.2.0
which 0.1.3
Dev dependencies
grinder any