0

I used angular in version 2.2.3 and always it worked good. When i upgraded to version 2.4.4 one error has ocurred (The error in picture below).

After hours searching what was happening i found that problem is because not is more possible use functions () => ExampleModule in attribute loadChildren of Router.

For use this i needed changed loadchildren: () => ExampleModule to loadchildren: 'path/example.module#ExampleModule', and angular worked as expected.

Now i want know if the function type () => is not more supported to use or this happened because i created a error ?

enter image description here

1 Answer 1

2

Carlinhos,

Looks like this was introduced today:

Changelog: router: enable loadChildren with function in aot

https://github.com/angular/angular/blob/master/CHANGELOG.md#244-2017-01-19

Looks like this has to do with lazy loading vs eager loading to fix AOT compilation, as the compiler was not available at the right time to resolve the route issue.

I'm thinking the issue might have to do with the function's return rather than the function itself -- it's expecting a factory to be returned now, so it's possible the function is no longer valid.

So, functions are still allowed, but I think they have to return a factory. It looks like strings were always allowed, and they work because they do not utilize a provided factory:

https://github.com/DzmitryShylovich/angular/blob/47b1031ba4552fd840817da9b7aa7da5780854a8/modules/%40angular/router/src/config.ts#L321

I think if you aren't using AOT/ lazy vs eager loading, you probably won't care about this and can use the string.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for help. I know that string mode and functions already used times ago, but i throwed this question because in angular site have no more explanations about function mode, only string mode. Now im not using AOT, but for everything to work as expected, i will continue writing with string mode. angular.io/docs/ts/latest/guide/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.