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

Add NgModule support to ngComponentOutlet #14043

Closed
mhevery opened this issue Jan 20, 2017 · 7 comments · Fixed by #14088
Closed

Add NgModule support to ngComponentOutlet #14043

mhevery opened this issue Jan 20, 2017 · 7 comments · Fixed by #14088

Comments

@mhevery
Copy link
Contributor

mhevery commented Jan 20, 2017

@Component({
  template: `
   <ng-container *ngComponentOutlet="child?.component; ngModule: child?.moduleFactory"></ng-container>
`
}) 
class MyApp {
   child: {component: Type<any>, moduleFactory: NgModuleFactory<T> };
}
@mhevery
Copy link
Contributor Author

mhevery commented Jan 20, 2017

/cc @jasonaden

@DzmitryShylovich
Copy link
Contributor

DzmitryShylovich commented Jan 23, 2017

@mhevery what is the use case? A component must be a part of a module or ngc will throw an error during compilation. So what's the purpose of moduleFactory arg? We will be able to create a component in the context of a different module?
Plus it's not user friendly syntax. In jit it have to be NgModule and in aot it have to be NgModuleFactory. We already faced a similar issue with router #14005 So we need a tool for automatic conversion.

@mhevery
Copy link
Contributor Author

mhevery commented Jan 23, 2017

@DzmitryShylovich Let me clarify

  1. yes Type can only be part of TypeFactory otherwise ngc would have an issue.
  2. Both AoT and JIT should always behave same in the API, and this does not change that.
  3. The change would allow the ngComponentOutlet to dynamically load a module into existence and then load a component from the that module.
  4. The use case is if someone wants to lazy load code, and then add the lazy loaded code into the page using ngComponentOutlet.

@DzmitryShylovich
Copy link
Contributor

DzmitryShylovich commented Jan 23, 2017

@mhevery

Both AoT and JIT should always behave same in the API, and this does not change that.

but we don't have NgModuleFactory in jit, do we?

@mhevery
Copy link
Contributor Author

mhevery commented Jan 24, 2017

but we don't have NgModuleFactory in jit, do we?

Yes we do: https://angular.io/docs/ts/latest/api/core/index/Compiler-class.html

@DzmitryShylovich
Copy link
Contributor

I've got it. Thx.

jasonaden pushed a commit to jasonaden/angular that referenced this issue Jan 24, 2017
Allow NgComponentOutlet to dynamically load a module, then load a component from
that module. Useful for lazy loading code, then add the lazy loaded code to the
page using NgComponentOutlet.

Closes angular#14043
jasonaden pushed a commit to jasonaden/angular that referenced this issue Jan 24, 2017
…rective

Allow NgComponentOutlet to dynamically load a module, then load a component from
that module. Useful for lazy loading code, then add the lazy loaded code to the
page using NgComponentOutlet.

Closes angular#14043
jasonaden added a commit to jasonaden/angular that referenced this issue Jan 24, 2017
…rective

Allow NgComponentOutlet to dynamically load a module, then load a component from
that module. Useful for lazy loading code, then add the lazy loaded code to the
page using NgComponentOutlet.

Closes angular#14043
jasonaden added a commit to jasonaden/angular that referenced this issue Jan 25, 2017
…rective

Allow NgComponentOutlet to dynamically load a module, then load a component from
that module. Useful for lazy loading code, then add the lazy loaded code to the
page using NgComponentOutlet.

Closes angular#14043
vicb pushed a commit that referenced this issue Jan 26, 2017
…rective (#14088)

Allow NgComponentOutlet to dynamically load a module, then load a component from
that module. Useful for lazy loading code, then add the lazy loaded code to the
page using NgComponentOutlet.

Closes #14043
juleskremer pushed a commit to juleskremer/angular that referenced this issue Aug 28, 2017
…rective (angular#14088)

Allow NgComponentOutlet to dynamically load a module, then load a component from
that module. Useful for lazy loading code, then add the lazy loaded code to the
page using NgComponentOutlet.

Closes angular#14043
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants