File tree Expand file tree Collapse file tree 6 files changed +152
-5
lines changed
Expand file tree Collapse file tree 6 files changed +152
-5
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,15 @@ Finally, initiate the generator:
4747``` bash
4848yo angular-require-fullstack
4949```
50- It will guide you from there
50+ It will guide you from there.
51+
52+ Also, you can create your own services/directives/controllers using our templates by doing:
53+
54+ ``` bash
55+ yo angular-require-fullstack:whatiwant
56+ ```
57+
58+ Replace ` whatiwant ` with the word ` controller ` , ` service ` or ` directive ` as you need. The rest is straightforward.
5159
5260### Getting To Know Yeoman
5361
Original file line number Diff line number Diff line change 11define ( [ '<%= appname %>' ] , function ( < %= appname % > ) {
22
3- 'use strict' ;
4- < %= appname % > . controller ( '<%= controllerName %>' , function ( $scope ) {
5-
6- } ) ;
3+ 'use strict' ;
4+ < %= appname % > . controller ( '<%= controllerName %>' , function ( $scope ) {
5+
6+ } ) ;
77
88} );
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ var yeoman = require ( 'yeoman-generator' ) ;
3+ var chalk = require ( 'chalk' ) ;
4+ var yosay = require ( 'yosay' ) ;
5+
6+ module . exports = yeoman . generators . Base . extend ( {
7+ initializing : function ( ) {
8+ this . pkg = require ( '../package.json' ) ;
9+
10+ } ,
11+ constructor : function ( ) {
12+ yeoman . generators . Base . apply ( this , arguments ) ;
13+ } ,
14+
15+ prompting : function ( ) {
16+ var done = this . async ( ) ;
17+
18+ // Have Yeoman greet the user.
19+ this . log ( yosay (
20+ 'Welcome to the brilliant ' + chalk . red ( 'AngularRequireFullstack' ) + ' generator! by ' + chalk . blue ( 'MONITS' )
21+ ) ) ;
22+
23+ this . log (
24+ 'I am going to scaffold a directive for you.'
25+ ) ;
26+
27+ var prompts = [ {
28+ type : 'input' ,
29+ name : 'directiveName' ,
30+ message : 'Directive name:' ,
31+ default : this . appname
32+ } ] ;
33+
34+ this . prompt ( prompts , function ( props ) {
35+ this . props = props ;
36+
37+ this . directiveName = this . props . directiveName ;
38+ // To access props later use this.props.someOption;
39+
40+ done ( ) ;
41+ } . bind ( this ) ) ;
42+ } ,
43+
44+ writing : {
45+ directive : function ( ) {
46+ // Directives
47+ this . fs . copyTpl (
48+ this . templatePath ( '/_directiveTemplate.js' ) ,
49+ this . destinationPath ( '/app/scripts/directives/' + this . directiveName + '.js' ) ,
50+ this
51+ ) ;
52+
53+ }
54+ } ,
55+
56+ end : function ( ) {
57+ this . log ( 'Run ' + chalk . red ( 'grunt serve' ) + ' to see the app in action or ' + chalk . blue ( 'grunt build' ) + ' when you are ready to deploy it' ) ;
58+ this . log ( 'Visit our blog at ' + chalk . blue ( 'https://medium.com/monits-blog' ) ) ;
59+ }
60+ } ) ;
Original file line number Diff line number Diff line change 1+ define ( [ '<%= appname %>' ] , function ( < %= appname % > ) {
2+
3+ 'use strict' ;
4+ < %= appname % > . directive ( '<%= directiveName %>' , function ( ) {
5+ return {
6+ restrict : 'E' ,
7+ template : '<span>Sample</span>'
8+ }
9+ } ) ;
10+
11+ } );
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ var yeoman = require ( 'yeoman-generator' ) ;
3+ var chalk = require ( 'chalk' ) ;
4+ var yosay = require ( 'yosay' ) ;
5+
6+ module . exports = yeoman . generators . Base . extend ( {
7+ initializing : function ( ) {
8+ this . pkg = require ( '../package.json' ) ;
9+
10+ } ,
11+ constructor : function ( ) {
12+ yeoman . generators . Base . apply ( this , arguments ) ;
13+ } ,
14+
15+ prompting : function ( ) {
16+ var done = this . async ( ) ;
17+
18+ // Have Yeoman greet the user.
19+ this . log ( yosay (
20+ 'Welcome to the brilliant ' + chalk . red ( 'AngularRequireFullstack' ) + ' generator! by ' + chalk . blue ( 'MONITS' )
21+ ) ) ;
22+
23+ this . log (
24+ 'I am going to scaffold a service for you.'
25+ ) ;
26+
27+ var prompts = [ {
28+ type : 'input' ,
29+ name : 'serviceName' ,
30+ message : 'Service name:' ,
31+ default : this . appname
32+ } ] ;
33+
34+ this . prompt ( prompts , function ( props ) {
35+ this . props = props ;
36+
37+ this . serviceName = this . props . serviceName ;
38+ // To access props later use this.props.someOption;
39+
40+ done ( ) ;
41+ } . bind ( this ) ) ;
42+ } ,
43+
44+ writing : {
45+ service : function ( ) {
46+ // Services
47+ this . fs . copyTpl (
48+ this . templatePath ( '/_serviceTemplate.js' ) ,
49+ this . destinationPath ( '/app/scripts/services/' + this . serviceName + '.js' ) ,
50+ this
51+ ) ;
52+
53+ }
54+ } ,
55+
56+ end : function ( ) {
57+ this . log ( 'Run ' + chalk . red ( 'grunt serve' ) + ' to see the app in action or ' + chalk . blue ( 'grunt build' ) + ' when you are ready to deploy it' ) ;
58+ this . log ( 'Visit our blog at ' + chalk . blue ( 'https://medium.com/monits-blog' ) ) ;
59+ }
60+ } ) ;
Original file line number Diff line number Diff line change 1+ define ( [ '<%= appname %>' ] , function ( < %= appname % > ) {
2+
3+ 'use strict' ;
4+ < %= appname % > . service ( '<%= serviceName %>' , function ( ) {
5+
6+ } ) ;
7+
8+ } );
You can’t perform that action at this time.
0 commit comments