googlearchive / generator-angularfire

Yeoman generator for AngularFire: Angular + Firebase apps
190 stars 52 forks source link

yo angularfire:route does not add controller or view #13

Closed wsgavin closed 9 years ago

wsgavin commented 10 years ago

generator-angularfire 0.8.2-7

Based on the documentation I expect that running yo angularfire:route newroute would:

All I see happening is the update to routes.js. I summarized the output below. Thoughts?

$ mkdir myapp
$ cd myapp
$ yo angularfire myapp

     _-----_
    |       |    .--------------------------.
    |--(o)--|    |    Welcome to Yeoman,    |
   `---------´   |   ladies and gentlemen!  |
    ( _´U`_ )    '--------------------------'
    /___A___\    
     |  ~  |     
   __'.___.'__   
 ´   `  |° ´ Y ` 

...

grunt-contrib-imagemin@0.7.2 node_modules/grunt-contrib-imagemin
├── pretty-bytes@0.1.2
├── async@0.7.0
└── imagemin@0.4.9 (stat-mode@0.2.0, ware@0.3.0, rimraf@2.2.8, nopt@3.0.1, tempfile@0.1.3, image-type@0.1.4, fs-extra@0.10.0, imagemin-svgo@0.1.1, imagemin-optipng@0.1.0, imagemin-gifsicle@0.1.1, imagemin-jpegtran@0.1.0, imagemin-pngquant@0.1.3)
app/index.html modified.
$ yo angularfire:route newroute
$ cd app/scripts
$ cat routes.js

...

.when('/newroute', {
        templateUrl: 'views/newroute.html',
        controller: 'NewrouteCtrl'
      })
      .otherwise({redirectTo: '/'});
  }])

...

$ cat app.js 
'use strict';

/**
 * @ngdoc overview
 * @name myappApp
 * @description
 * # myappApp
 *
 * Main module of the application.
 */
angular.module('myappApp', [
    'ngAnimate',
    'ngCookies',
    'ngResource',
    'ngRoute',
    'ngSanitize',
    'ngTouch',
    'firebase',
    'firebase.utils',
    'simpleLogin'
  ]);
$ cd controllers
$ ls -al
total 16
drwxr-xr-x 6 user staff  204 Sep  7 21:51 .
drwxr-xr-x 8 user staff  272 Sep  7 21:51 ..
-rw-r--r-- 1 user staff 1644 Sep  7 21:51 account.js
-rw-r--r-- 1 user staff  909 Sep  7 21:51 chat.js
-rw-r--r-- 1 user staff 1167 Sep  7 21:51 login.js
-rw-r--r-- 1 user staff  315 Sep  7 21:51 main.js
$ cd ../../views
$ ls
$ ls -al
total 16
drwxr-xr-x  6 user staff  204 Sep  7 21:51 .
drwxr-xr-x 12 user staff  408 Sep  7 21:51 ..
-rw-r--r--  1 user staff 1969 Sep  7 21:51 account.html
-rw-r--r--  1 user staff  358 Sep  7 21:51 chat.html
-rw-r--r--  1 user staff 1171 Sep  7 21:51 login.html
-rw-r--r--  1 user staff  792 Sep  6 10:34 main.html
wsgavin commented 10 years ago

I'm not extremely familiar with yeoman generators but I believe the problem exists below from route/index.js

  if( !skipFiles ) {
    this.hookFor('angular:controller');
    this.hookFor('angular:view');
  }

Guessing that skipFiles needs to be set to false, but not sure how that works. Doing a quick search, this variable names only exists in the route/index.js file.

katowulf commented 10 years ago

@wsgavin thanks for this. It looks like, in some cases, a second argument is being passed into this method inadvertently by some yeoman process. We can probably just change that to if( skipFiles !== true ) to resolve the issue. I'll put this in the next release.

wsgavin commented 10 years ago

In the current generator-angular repo I could not find a skipFiles reference either. Guessing this option would be nice but skipFiles doesn't apear to get assinged (i.e. undefined) anyware which is the cause of the resulting behavior. Again, I am not too familiar w/generators and how they work.

katowulf commented 10 years ago

It's being assigned to true app/index.js calls. I don't think they are actually being skipped; I think the problem is that the route command is calling angular:method instead of angularfire:method. I'll fix this up.

In the interim, call angularfire:controller and angularfire:view manually.

wsgavin commented 10 years ago

Thanks for the response.

karensg commented 10 years ago

Handy tool! Any perspectives about this issue?

katowulf commented 10 years ago

Until the next release, just call angularfire:controller and angularfire:view manually.

karensg commented 10 years ago

I know, it works. Was just wondering.. :)