Issue 1:
I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Currently when I try to reuse the same TemplateRef instance for multiple items it renders wrong view

Expected behavior

It should render a separate view inside each view container

Minimal reproduction of the problem with instructions

https://plnkr.co/edit/PZe5XnmJ2KoJ99ts33F9?p=preview

Currently you will see 2 words "Enabled".

Should be "

{ "enabled": true } Enabled

{ "enabled": false } disabled" (as in https://plnkr.co/edit/rZuCs8O7YE4fYplfI3gF?p=preview)

What is the motivation / use case for changing the behavior?

I have a slider with hundreds of slides and want to optimise DOM by using lazy DOM creation. For this I need to use template reference. Eventually it's something like this:

<lazy-slides [items]="files">
<template let-file="item">
<preview-file [src]="file.url"></preview-file>
</template>
</lazy-slides>

Then using ngFor and ngTemplateOutlet I put this template for first 5 items and when user slides I change references inside array.

Please tell us about your environment:

npm: 3.9.3

OSX EI Capitan 10.11.5

Atom

Chrome 54.0.2840.98

Angular version: 2.0.X

Reproducible starting from 2.2.0, the same in 2.3.0. Works properly in 2.2.0-rc.0 and older ( https://plnkr.co/edit/rZuCs8O7YE4fYplfI3gF?p=preview )

Browser:

Chrome 54.0.2840.98

Language: all

Issue 2:
I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Currently when you have ContentChild(TemplateRef) it is not working correctly. Because after init you get different TemplateRef object as you get after another ContentCheck.

If you have following html

<grabber>
<template>
<div style="background-color: #FF00FF;">
<span>ok</span>
<div style="background-color: #00FFFF;" *ngIf="true">bad</div>
</div>
</template>
</grabber>

If your grabber component have @ContentChild(TemplateRef) and in ngAfterContentInit() method you will use this template, <template> element is used.

But if you use this template again, not during ngAfterContentInit() method call you get <div style="background-color: #00FFFF;" *ngIf="true">bad</div> template.

This is pretty awfull bug.

Thanks for help

Expected behavior

It should return same template during init phase and also after another check of content. And also there is no explaination why descendants: true were set. This means that correct template in this case is div? If so, then during init phase this is not considered.

Minimal reproduction of the problem with instructions

Here is plunker where you can see problem described above. https://plnkr.co/edit/FWqPGlsENMJZHhD4SOCd?p=preview

If you add another template you see only <div> element.

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

Windows 10, Visual Studio Code, npm, Connect server

Angular version: >= 2.2.0

Browser: all

Language: TypeScript 2.0.9