Giter Club home page Giter Club logo

Comments (5)

christopherthielen avatar christopherthielen commented on July 16, 2024

are you on the official beta.3 build? I don't think beta.3 supports the callback to loadNgModule yet.

beta.4 and beta.5 are going to change ng module loading significantly. stay tuned.

from angular.

yuxiaomin avatar yuxiaomin commented on July 16, 2024

Hello, I am on the official beta.4 build and run into the same issue when I used the callback function to lazy load.

Following the docs I also tried this way to lazy load the module

var stocksState = {
  name: 'stocks',
  url: '/stocks',
  lazyLoad: loadNgModule('stocks/client/components/app.module.child#ChildAppModule')
}

In the systemjs.config
I got this error

ui-router-ng2.js:6374 TransitionRejection(type: 6, message: The transition errored, detail: Error: DI Error)
$defaultErrorHandler @ ui-router-ng2.js:6374
(anonymous) @ ui-router-ng2.js:6706
e.invoke @ zone.min.js:1
onInvoke @ core.umd.js:4427
e.invoke @ zone.min.js:1
t.run @ zone.min.js:1
(anonymous) @ zone.min.js:1
e.invokeTask @ zone.min.js:1
onInvokeTask @ core.umd.js:4418
e.invokeTask @ zone.min.js:1
t.runTask @ zone.min.js:1
a @ zone.min.js:1
invoke @ zone.min.js:1
ui-router-ng2.js:6376 Error: DI Error
    at NoProviderError.d (http://localhost:3000/vendor/zonejs/dist/zone.min.js:1:11171)
    at NoProviderError.BaseError [as constructor] (http://localhost:3000/vendor/@angular/core/bundles/core.umd.js:1186:20)
    at NoProviderError.AbstractProviderError [as constructor] (http://localhost:3000/vendor/@angular/core/bundles/core.umd.js:1371:20)
    at new NoProviderError (http://localhost:3000/vendor/@angular/core/bundles/core.umd.js:1411:20)
    at ReflectiveInjector_._throwOrNull (http://localhost:3000/vendor/@angular/core/bundles/core.umd.js:3394:23)
    at ReflectiveInjector_._getByKeyDefault (http://localhost:3000/vendor/@angular/core/bundles/core.umd.js:3433:29)
    at ReflectiveInjector_._getByKey (http://localhost:3000/vendor/@angular/core/bundles/core.umd.js:3380:29)
    at ReflectiveInjector_.get (http://localhost:3000/vendor/@angular/core/bundles/core.umd.js:3140:25)
    at AppModuleInjector.NgModuleInjector.get (http://localhost:3000/vendor/@angular/core/bundles/core.umd.js:8996:56)
    at loadModuleFactory (http://localhost:3000/vendor/ui-router-ng2/_bundles/ui-router-ng2.js:8501:28)
    at eval (http://localhost:3000/vendor/ui-router-ng2/_bundles/ui-router-ng2.js:8481:16)
    at lazyLoadState (http://localhost:3000/vendor/ui-router-ng2/_bundles/ui-router-ng2.js:6098:30)
    at eval (http://localhost:3000/vendor/ui-router-ng2/_bundles/ui-router-ng2.js:6069:40)
    at Array.map (native)
    at lazyLoadHook (http://localhost:3000/vendor/ui-router-ng2/_bundles/ui-router-ng2.js:6069:10)

I search the github issues and found that somebody reported the similar issue before but type of TransitionRejection is 6 which is different.

The above lazy loading works well if I use @angular/router but I strongly hope that ui-router-ng2 can support this well too. We built a large angular1 app intensively depending on the ui-router. Now we immigrate to ng2 I do not want to go away from ui-router.

from angular.

christopherthielen avatar christopherthielen commented on July 16, 2024

Possibly related angular/angular#14343

from angular.

about-code avatar about-code commented on July 16, 2024

"No NgModule metadata found for '[object Object]"

In the setup which I had in angular/angular#14343 the part [object Object] resolved to a correct module class name. Further I had a pure Angular2 setup with @angular/router and hadn't to use System.import myself to load the module.

Given that the error message printed for @lexigren is logged by the same piece of angular code like it is in my case, then the code which produces the message attempts to infer the class name from decorator metadata. If the class name resolves to [object Object] in @lexigren's case it may indeed be the case that the result returned by the SystemJS-Promise callback does not match with what angular expects.

@lexigren If you explore angular/angular#14343 you'll see that what is exported in my case is the result of a _decorate()call. Not sure what the value of result.ProductsModuleis in your case. I guess the issue might be easier to investigate if you could provide the part of product.module where the class is decorated and exported as well as your SystemJS Loader config, if that's possible.

from angular.

christopherthielen avatar christopherthielen commented on July 16, 2024

Lazy loading has changed significantly since this issue was filed. I don't think the issue is relevant anymore. If it's still an issue, please let me know and we can reopen. Please view the sample app for and the lazy loading guide for current lazy loading practices.

from angular.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.