Skip to content

Conversation

@mhevery
Copy link
Contributor

@mhevery mhevery commented Dec 11, 2016

feat(NgComponentOutlet): add NgComponentOutlet directive

Add NgComponentOutlet directive that can be used to dynamically create
host views from a supplied component.

Closes #11168
Takes over PR #11235

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

@shlomiassaf
Copy link
Contributor

shlomiassaf commented Dec 11, 2016

@mhevery I have pushed the updated code to my branch.

Tests are passing.

It includes a rebase + all the requested changed except the namings.
(support for * syntax)

I didn't have time to edit my WIP comminets so commits should be squashed :)

There are some lines of codes commented out in the tests since Output is not supported in * syntax.

I think you should use it as a baseline

https://github.com/shlomiassaf/angular/tree/ng-component-outlet

@pkozlowski-opensource pkozlowski-opensource added the area: common Issues related to APIs in the @angular/common package label Dec 12, 2016
@mhevery
Copy link
Contributor Author

mhevery commented Dec 14, 2016

@shlomiassaf thanks, i am also making sure that ngTemplateOutlet and ngComponentOutlet are consistent and adding documentation. At this point I think the two have diverged too much to be able to reuse your branch. Sorry.

@mhevery mhevery force-pushed the pr-11235 branch 3 times, most recently from 7b04d63 to 6406369 Compare December 14, 2016 22:54
@mhevery mhevery requested review from IgorMinar and vicb December 14, 2016 23:00
@mhevery
Copy link
Contributor Author

mhevery commented Dec 14, 2016

@vicb ready for review.

@MaximCrabbe
Copy link

So how long does it take on average for a PR like this to be reviewed? (Just would like to know, not 'pushing'). This NgComponentOutlet seems usefull!

@shlomiassaf
Copy link
Contributor

shlomiassaf commented Dec 31, 2016 via email

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about @Input('ngTemplateOutletContext') public context: Object;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it is better as-is

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about @Input('ngTemplateOutlet') public template: TemplateRef<any>;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it is better as-is

@vicb
Copy link
Contributor

vicb commented Jan 4, 2017

LGTM, please rebase and consider the minor comments.

@vicb vicb added area: core Issues related to the framework runtime action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews pr_state: LGTM labels Jan 4, 2017
@mhevery
Copy link
Contributor Author

mhevery commented Jan 4, 2017

Rebased

@mhevery mhevery added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Jan 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we change it so only views we've created are destroyed here? In theory we could have multiple directives sitting on the same <template> element, they could be creating their own views and this logic would mess up views created by other directives, no?

This is what is done in the template outlet:

if (this._viewRef) {
this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._viewRef));
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. Fixed

BREAKING CHANGE:

- Deprecate `ngOutletContext`. Use `ngTemplateOutletContext` instead
@mhevery mhevery added action: merge The PR is ready for merge by the caretaker and removed action: merge The PR is ready for merge by the caretaker labels Jan 6, 2017
Add NgComponentOutlet directive that can be used to dynamically create
host views from a supplied component.

Closes angular#11168
Takes over PR angular#11235
// #docregion CompleteExample
@Injectable()
class Greeter {
suffix = '!'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[32, 15]: Missing semicolon.

* Instantiates a single {@link Component} type and inserts its Host View into current View.
* `NgComponentOutlet` provides a declarative approach for dynamic component creation.
*
* `NgComponentOutlet` requires a component type, if a falsy value is set the view will clear and
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be if a false value instead of if a falsy value.

@matsko
Copy link
Contributor

matsko commented Jan 9, 2017

@mhevery please fix CI issues.

@matsko
Copy link
Contributor

matsko commented Jan 9, 2017

Landed as 8578682

@matsko matsko closed this Jan 9, 2017
@MaximCrabbe
Copy link

Sorry I am not so familiar with how big open source projects work. Is this feature now implemented? (I think so in 8578682 commit) however what version of angular do I need, I guess it will be 2.5 or something ?

@DzmitryShylovich
Copy link
Contributor

DzmitryShylovich commented Jan 12, 2017

@mhevery mhevery deleted the pr-11235 branch June 2, 2017 17:07
@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 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: common Issues related to APIs in the @angular/common package area: core Issues related to the framework runtime cla: no

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] NgComponentOutlet

9 participants