npm install && bower install
- angular:controller
- angular:directive
- angular:filter
- angular:route
- angular:service
- angular:provider
- angular:factory
- angular:value
- angular:constant
- [angular:decorator] (#decorator)
- angular:view
Note: Generators are to be run from the root directory of your app.
Generates a controller and view, and configures a route in app/scripts/app.js
connecting them.
Example:
yo angular:route myroute
Produces app/scripts/controllers/myroute.js
:
angular.module('myMod').controller('MyrouteCtrl', function ($scope) {
// ...
});
Produces app/views/myroute.html
:
<p>This is the myroute view</p>
Generates a controller in app/scripts/controllers
.
Example:
yo angular:controller user
Produces app/scripts/controllers/user.js
:
angular.module('myMod').controller('UserCtrl', function ($scope) {
// ...
});
Generates a directive in app/scripts/directives
.
Example:
yo angular:directive myDirective
Produces app/scripts/directives/myDirective.js
:
angular.module('myMod').directive('myDirective', function () {
return {
template: '<div></div>',
restrict: 'E',
link: function postLink(scope, element, attrs) {
element.text('this is the myDirective directive');
}
};
});
Generates a filter in app/scripts/filters
.
Example:
yo angular:filter myFilter
Produces app/scripts/filters/myFilter.js
:
angular.module('myMod').filter('myFilter', function () {
return function (input) {
return 'myFilter filter:' + input;
};
});
Generates an HTML view file in app/views
.
Example:
yo angular:view user
Produces app/views/user.html
:
<p>This is the user view</p>
Generates an AngularJS service.
Example:
yo angular:service myService
Produces app/scripts/services/myService.js
:
angular.module('myMod').service('myService', function () {
// ...
});
You can also do yo angular:factory
, yo angular:provider
, yo angular:value
, and yo angular:constant
for other types of services.
Generates an AngularJS service decorator.
Example:
yo angular:decorator serviceName
Produces app/scripts/decorators/serviceNameDecorator.js
:
angular.module('myMod').config(function ($provide) {
$provide.decorator('serviceName', function ($delegate) {
// ...
return $delegate;
});
});
By default, new scripts are added to the index.html file. However, this may not always be suitable. Some use cases:
- Manually added to the file
- Auto-added by a 3rd party plugin
- Using this generator as a subgenerator
To skip adding them to the index, pass in the skip-add argument:
yo angular:service serviceName --skip-add
The following packages are always installed by the app generator:
- angular
- angular-mocks
- angular-scenario
The following additional modules are available as components on bower, and installable via bower install
:
- angular-strap
- jquery
- bootstrap
- angular-motion
- angular-route
- angular-animate
- angular-google-maps
- angular-qrcode
- angular-webstorage
- angular-resource
- angular-sanitize
- angular-scrollto
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.
Running grunt test
will run the unit tests with karma.
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/.