Adrian Mitev
Adrian Mitev

Reputation: 4752

Can't get ocLazyLoad to work with ES6 (Traceur and modules in AMD mode)

I have a project where I develop my code in ES6 format using Traceur and have set the module loading to be transpiled to AMD style in order to use RequireJS. I have the following code (got it from the ocLayLoad sample projects)

angular.module("testApp",[]).directive("sayHello", function() {
  return {
    scope: {
        to: '@to'
    },
    restrict: "E",
    template: '<p>Hello {{to}}</p>'
  };
});

If I use a pure ES5 style with ocLazyLoad + RequireJS everything works fine. However when the class gets processed by Traceur it is wrapped in a define() function and looks like this:

define([], function() {
  "use strict";
  angular.module("testApp", []).directive("sayHello", function() {
    return {
      scope: {to: '@to'},
      restrict: "E",
      template: '<p>Hello {{to}}</p>'
    };
  });
  return {};
});

However, in this case for some reason the lazy loading doesn't work. It throws an error that the module "testApp" is not registered within angular. Idea what is preventing ocLazyLoad from loading the module?

Upvotes: 2

Views: 229

Answers (0)

Related Questions