npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

generator-ngmodule

v0.0.2

Published

This Yeoman generator creates a folder with a module-declaration file, a controller, a view, and a test file.

Downloads

26

Readme

DEPRECATED

This package has not been maintained for over a year. It was originally meant as a learning experiment. Do not use as-is. It will not work at all with Angular version 2 or greater.

generator-ngmodule

This Yeoman generator creates a "module" in the sense of a collection of files needed to produce a state in your Angular app. This folder consist of a module-declaration file, a controller, a view, and a Jasmine test file.

Getting Started

Make sure you have Yeoman installed globally.

npm install -g yo

Now, install this generator.

npm install -g generator-ngmodule

To generate a module, navigate to the folder in your Angular app where you wish to create a module and invoke the generator with the module name as a parameter.

yo ngmodule widgets

The generator will list the files it creates.

create widgets/widgets.app.js
create widgets/widgets.controller.js
create widgets/widgets.controller.spec.js
create widgets/widgets.view.html

Folder Structure

The ngmodule generator creates a folder structure similar to how the MEAN.JS project lays out their module folders. If you are used to a more Rails-like folder structure (all controllers in one folder, all services in another folder, all views in a third folder, etc.), this structure may seems strange at first, but it provides the benefit that files are grouped together by what they do, and NOT by what kind of file they are.

|---widgets 
|-----widgets.app.js 
|-----widgets.controller.js
|-----widgets.spec.js
|-----widgets.view.html

Controller

The ngmodule generator creates a controller that uses the controllerAs-vm syntax recommended by John Papa in his Angular style guide.

For now, it also injects $scope as a dependency. I plan to make that option and add more DI options in the future.

Routing

The ngmodule generator is routing-agnostic; so, you will have to add routing configuration to use the controller and template it generates based on the routing system you use.

Here is an example of adding a state for the module if you are using ui-router.

$stateProvider
    .state('widgets', {
        url: '/widgets',
        controller: 'widgetsController',
        controllerAs: 'vm',
        templateUrl: 'widgets.view.html'
    })

Testing

The ngmodule generator creates a scaffold Jasmine test file for the controller, which includes a beforeEach() block and some basic tests to get you started.

Styling

The styling in the view file produced is very minimal. Unless you are just starting out, you will probably not use this generator as-is, but instead fork it and adapt it to your particular app.

Roadmap

The ngmodule generator is meant to automate the process of creating new modules in an already-existing Angular app. It is not for generating a full app from scratch. It may be helpful if you don't want to be tied down to a full-blown app generator, like angular-fullstack.

I hope to add more options for individual modules in the future.