Yeoman generator for AngularJS - lets you quickly set up a project with sensible defaults and best practices. Extended to enhance the defaults by integrating with bootstrap-ui(optional) and Restangular.
Roadmap for upcoming plans/features/fixes
Install generator-angular-resources:
npm install -g generator-angular-resources
Make a new directory, and cd into it:
mkdir my-new-project && cd $_
Run yo angular, optionally passing an app name:
yo angular [app-name]
Run grunt for building and grunt serve for preview
Available generators [EXTENSIONS]:
Available generators [DEFAULTS]:
- angular-resources (aka angular-resources:app)
- angular-resources:controller
- angular-resources:directive
- angular-resources:filter
- angular-resources:route
- angular-resources:service
- angular-resources:provider
- angular-resources:factory
- angular-resources:value
- angular-resources:constant
- angular-resources:decorator
- angular-resources:view
Note: Generators are to be run from the root directory of your app.
Sets up a new AngularJS app, generating all the boilerplate you need to get started. The app generator also optionally installs Bootstrap and additional AngularJS modules, such as angular-resource (installed by default).
Example:
yo angularGenerates a controller and view, and configures a route in app/scripts/app.js connecting them.
Produces app/scripts/app.js:
.when('/user/create', {
templateUrl: 'views/user-create.html',
controller: 'UserCreateCtrl'
})
.when('/user/:id', {
templateUrl: 'views/user-edit.html',
controller: 'UserEditCtrl'
})
.when('/user', {
templateUrl: 'views/user-list.html',
controller: 'UserListCtrl'
})
// ...
});Example:
yo angular-resources:resourceroute userProduces app/scripts/controllers/user.js:
angular.module('myMod').controller('UserCreateCtrl', function ($scope, Restangular) {
// ...
});
angular.module('myMod').controller('UserEditCtrl', function ($scope, Restangular, $routeParams) {
// ...
});
angular.module('myMod').controller('UserListCtrl', function ($scope, Restangular) {
// ...
});Produces app/views/user-create.html:
<form></form>Produces app/views/user-edit.html:
<form></form>Produces app/views/user-list.html:
<table></table>Explicitly provide route URI
Example:
yo angular-resource:resourceroute user --uri=my/routeProduces controller and view as above and adds a route to app/scripts/app.js
with URI my/route
Generates a controller in app/scripts/controllers.
Example:
yo angular-resource:resourcecontroller userProduces app/scripts/controllers/user.js:
angular.module('myMod').controller('UserCreateCtrl', function ($scope, Restangular) {
// ...
});
angular.module('myMod').controller('UserEditCtrl', function ($scope, Restangular, $routeParams) {
// ...
});
angular.module('myMod').controller('UserListCtrl', function ($scope, Restangular) {
// ...
});Generates an HTML view file in app/views.
Example:
yo angular-resources:resourceview userProduces app/views/user-create.html:
<form></form>Produces app/views/user-edit.html:
<form></form>Produces app/views/user-list.html:
<table></table>The following packages are always installed by the app generator:
- angular
- angular-mocks
- angular-scenario
- angular-ui
- restangular
The following additional modules are available as components on bower, and installable via bower install:
- angular-cookies
- angular-loader
- angular-resource
- angular-sanitize
All of these can be updated with bower update as new versions of AngularJS are released.
Yeoman generated projects can be further tweaked according to your needs by modifying project files appropriately.
You can change the app directory by adding a appPath property to bower.json. For instance, if you wanted to easily integrate with Express.js, you could add the following:
{
"name": "yo-test",
"version": "0.0.0",
...
"appPath": "public"
}
This will cause Yeoman-generated client-side files to be placed in public.
Running grunt test will run the unit tests with karma.