Closed
Description
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:
Current behavior
Accessing ngModel
using templateRef doesn't work when it is inside *ngIf
statement.
Expected behavior
It should work.
Minimal reproduction of the problem with instructions
<ng-container *ngIf="true">
<mat-form-field>
<mat-select [(ngModel)]="selectedValue" placeholder="Select value" #selectElBroken="ngModel">
<mat-option *ngFor="let item of [1,2,3]" [value]="item">{{item}}</mat-option>
</mat-select>
</mat-form-field>
</ng-container>
{{selectElBroken?.dirty}}
selectElBroken
will be undefined
https://stackblitz.com/edit/angular-rr54wp-template-form-bug
What is the motivation / use case for changing the behavior?
I need to get state of template-driven form field which is inside *ngIf
.
Environment
Angular version: 6.1.4
Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
For Tooling issues:
- Node version: XX
- Platform:
Others:
I'm pretty sure it is related to #8563
Metadata
Metadata
Assignees
Labels
No labels