yaru22 / ng-html2js

Standalone script to turn Angular template into js and put it in a module.
32 stars 19 forks source link

circular module reference when using this with browserify #4

Closed javoire closed 10 years ago

javoire commented 10 years ago

Hey. I've created a browserify transform plugin based on this package. However, an issue arises with circular references to module as described in this issue: https://github.com/javoire/browserify-ng-html2js/issues/3

A possible solution would be to rename module to something else, like ngModule. It shouldn't really matter what since its only used internally in that module anyway.

What do you think?

yaru22 commented 10 years ago

Hi @javoire, thanks for suggesting that. Renaming module to ngModule is not a problem at all. However, looking at my code again, I don't even think that's going to work.

(function(module) { // <-- ng-html2js generated
    try {
      module = angular.module('templates');
    } catch (e) {
      module = angular.module('templates', []);
    }
    module.run(["$templateCache", function($templateCache) {
      $templateCache.put('home.html',
        '<h2>Home</h2>\n' +
        '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate commodi, dolor vero. Temporibus eaque aliquam repudiandae dolore nemo, voluptas voluptatibus quod at officiis, voluptates adipisci pariatur expedita, quos ducimus inventore.</p>\n' +
        '');
    }]);
  })();  // <-- I need to pass in an argument here.

I'll change so that you can pass in an argument of your choice there. I'm not sure how you are integrating with browserify but that should help. Let me know if you discover more issues.

yaru22 commented 10 years ago

See f98c7001a647bc43311a0e89c2fb1add047944a2 and 59a940bfaef7eb5158580e716d59d05d44a5644f.

javoire commented 10 years ago

Great, thanks man.