Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use a variable to set dependencies of a module #24

Open
pire opened this issue Mar 13, 2015 · 5 comments
Open

Cannot use a variable to set dependencies of a module #24

pire opened this issue Mar 13, 2015 · 5 comments

Comments

@pire
Copy link

pire commented Mar 13, 2015

It seems like dependencies cannot be set in a variable?

// OK
angular.module(moduleName, []);

// fails
var dependencies = [];
angular.module(moduleName, dependencies);

I get the following trace

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
Error: Error in parsing: "/config.js", Cannot call method 'map' of undefined
@topherfangio
Copy link

Any updates on this? I'm hitting the exact same issue.

@pire
Copy link
Author

pire commented May 6, 2015

Haven't heard a peep - I've defaulted to not using a variable for now but not ideal...

@joakimbeng
Copy link
Member

Sorry. I haven't had the time to investigate this yet...
It's the ng-dependencies module that must be improved for this to work.

I gladly accept PR's for this if someone would like to help out!

@pire
Copy link
Author

pire commented May 7, 2015

Awesome, thanks for pointing in the right direction @joakimbeng :) I'll see if I can find some time to help out with that.

@LeonardoGentile
Copy link

I had a similar issue while customizing uiBreadcrumbs. It seems that anytime I declared a module name using a variable to hold it angular-file-sort was considering that files two times, so gulp-inject was adding it two times to index.html.
This is the example that did not work:

(function() {

    /**
     * Config
     */
    var moduleName = 'angularUtils.directives.uiBreadcrumbs';
    var templateUrl = 'directives/uiBreadcrumbs/uiBreadcrumbs.tpl.html';

    /**
     * Module
     */
    var module;
    try {
        module = angular.module(moduleName);
    } catch(err) {
        // named module does not exist, so create one
        module = angular.module(moduleName, ['ui.router']);
    }
    module.directive('uiBreadcrumbs', ['$interpolate', '$state', function($interpolate, $state) {
       // ...    
    }]);
})

Things work if we remove the variable module name logic using instead the normal module declaration

(function() {
  angular.module('angularUtils.directives.uiBreadcrumbs', ['ui.router'])
    .directive('uiBreadcrumbs', ['$interpolate', '$state', function($interpolate, $state) {
       // ...    
    }]);
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants