I have this mat-toggle-group:
<mat-button-toggle-group #group="matButtonToggleGroup">
<mat-button-toggle value="specific">
Specific
</mat-button-toggle>
<mat-button-toggle value="general" checked>
General
</mat-button-toggle>
</mat-button-toggle-group>
and i have these 2 fields.
<div *ngIf="group.value == specific">
<mat-form-field id="id">
<input matInput placeholder="Insert seed Id">
</mat-form-field>
<mat-form-field id="id">
<input matInput placeholder="Insert affiliate rank">
</mat-form-field>
</div>
As you can see in the second code snippet i'm trying to include the fields in the DOM only when Specific has been selected. However this does not work. I've read here How to access Angular 2 template variable in ngIf
that the template variable is not accessible outside the template element and that i should use @ViewChild
instead. I found this tutorial on how to use ViewChild https://blog.angular-university.io/angular-viewchild/. But its about referencing a component (ColorSampleComponent) that has been made by the user himself. I am trying to reference my buttontogglegroup like so:
@ViewChild(matButtonToggleGroup)
group: matButtonToggleGroup;
But it doesn't work because i can't import matButtonToggleGroup, i can only import the module but thats not the same thing.
Can anyone give me some pointers on how to get the value of the togglegroup for use in the ngIf directive? Thank you