0.0.9 • Published 9 years ago

generator-angular-module-bp v0.0.9

Weekly downloads
16
License
MIT
Repository
github
Last release
9 years ago

generator-angular-module-bp

An AngularJS module generator following John Papa's best practices

Installation

First, install Yeoman and generator-angular-module-bp using npm (we assume you have pre-installed node.js).

npm install -g yo
npm install -g generator-angular-module-bp

Then generate your new project:

yo angular-module-bp

OR

yo angular-module-bp <module name>

###What is a Module An AngularJS module is what I would call the minimum required for a fully functional AngularJS application. Its file structure goes like this :

Exemple of a Doctor Module:
src
├── doctor
|   ├── views
|   |   ├── doctor.main.view.html
|   ├── doctor.module.js
|   ├── doctor.config.js
|   ├── doctor.run.js
|   └── doctor.controller.js

Now lets dive into the details.

####The Module File

the module file contains the declaration of the module only and is to be included in the index.html file before any use of the module in the project

(function() {
    "use strict";
    angular.module('doctor', []);
})();

####The configuration File

the configuration file will contain all the configuration required by the module to run properly

(function() {
    "use strict";
    angular
        .module('doctor')
        .config(configure);

    configure.$inject = [];
    function configure() {
    }

})();

####The run File

the run file will contain all code that will need to be run at the initialisation of the module (not always required but generated by default just in case)

(function() {
    "use strict";
    angular
        .module('doctor')
        .run(runBlock);

    runBlock.$inject = [];
    function runBlock() {

    }

})();

####The controller

the controller file will generate an empty controller with the name of the module to run as the main controller of the module or to be changed latter upon the user's needs.

(function() {
    "use strict";
    /**
     * Module: doctor
     * Controller: DoctorController
     * Description:
     * 
     */   angular.module('doctor').controller('DoctorController', DoctorController);

    function DoctorController() {

    }

})();

The Controller Generator

The controller generator is a generator that allows its user to generate extra controllers inside an already existing AngularJS Module

it is a sub generator that is automatically installed with the main generator and is to be run with the following commande

yo angular-module-bp:controller

and it will ask for the name of your module and the name of your controller and then generate a controller similar to the one generated by the module generator

Exemple:

What is the name of your main Module (Your APP)?app
What is the name of your module?doctor
What is the name of your new controller (lowercase without . or Controller)?new

this will generate the following

doctor.new.controller.js

(function() {
    "use strict";

    /**
     * Module: doctor
     * Controller: 
     * Description:
     * 
     */
    angular.module('doctor').controller('DoctorNewController', DoctorNewController);

    function DoctorNewController() {
    }
})();

Getting To Know Yeoman

Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced. Feel free to learn more about him.

License

MIT © Djadoun Mohamed Abderrezak

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago

0.0.0

9 years ago