angular / angular/angular

ng-if on root elements of projected content fails to render on initialisation

Ouverte
#16,685 4 commentaires 3 réactions 0 personnes assignées Voir sur GitHub
area: upgrade effort1: hours freq1: low P4 state: confirmed type: bug/fix
Langage dominant
TypeScript
Étoiles
101k
Forks
27.5k
Merge moyen
1 j 19 h
PR mergées (30 j)
288

Description

**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**
When developing a hybrid app with ngUpgrade, If you have an AngularJS component that contains a downgraded Angular Component in the template and this one implements content projection and wraps the `ng-content` element in an element that contains the `*ngIf` directive. Any root element of the AngularJS content that has the `ng-if` directive attribute will not be rendered until you re-toggle the property or expression bound to the attribute.

**Expected behavior**
The content is correctly projected and all directives properly evaluated without having to add extra wrapping elements.

**Minimal reproduction of the problem with instructions**
[Plunker with examples](https://plnkr.co/edit/ogPxZ11S82FsTdFdRwuf?p=preview)

_Example 1_
When using an Angular component that contains content projection within an AngularJS component, any root elements of the projected content that contain `ng-if` will fail to render on initialisation but by toggling the `ng-if` value they will then render correctly as per the evaluated value of the `ng-if`.

_Example 2_
When using an Angular component that contains content projection within an AngularJS component, any root elements of the projected content that contain `ng-if` will fail to render on initialisation, but by adding an element at the root of the projected content without `ng-if`, they will then render correctly.

_Example 3_
When using an Angular component that contains content projection within an AngularJS component, any root elements of the projected content that contain `ng-if` will fail to render on initialisation, but by removing the `*ngIf` on any parent elements of the Angular component will make it then render correctly.

**What is the motivation / use case for changing the behavior?**
So that AngularJS content that contain `ng-if` on root elements of the content to be projected can be be correctly projected into Angular components that contain `*ngIf` on any parents of the `ng-content`.

**Please tell us about your environment:**
OS: Windows 10

* **Angular version:** 4.1.0
* **AngularJS version:** 1.6.1

* **Browser:** All

* **Language:** TypeScript 2.2.0

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par la reproduction Plunker liée et comparez les trois exemples impliquant ngUpgrade, content projection, ng-content, *ngIf et ng-if. Analysez pourquoi les éléments racine AngularJS projetés ne sont pas évalués lors de l’initialisation lorsqu’un élément parent Angular avec *ngIf est présent. Le travail est terminé lorsque le contenu ng-if projeté s’affiche correctement lors de l’initialisation, sans wrapping ni basculement supplémentaires.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, angularjs, typescript
Domaine
frontend
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Active
Clarté
Plutôt claire
Accessibilité débutants
48/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.