I have a two dropdowns that looks like this:
so my plan is to load all subcategories, but I would like to display in dropdown only these which are related to selected Category ( that one which contain ParentId as Id of selected Category).
And here is my code:
<!--Category-->
<div class="form-group">
<label class="control-label dash-control-label col-xs-3">Category:</label>
<div class="col-xs-9">
<select class="form-control select2" style="width: 100%;"
data-minimum-results-for-search="Infinity" name="articleCategory" #articleCategory="ngModel" required [(ngModel)]="article.mainCategory">
<option disabled [ngValue]="null">-/-</option>
<option [ngValue]="category" *ngFor="let category of mainGroups">{{category.title}}</option>
</select>
</div>
</div>
<!--Subcategory-->
<div class="form-group">
<label class="control-label dash-control-label col-xs-3">Sub category:</label>
<div class="col-xs-9">
<select class="form-control select2" style="width: 100%;" name="subCategory" #subCategory="ngModel" required [(ngModel)]="article.subCategory">
<option disabled [ngValue]="null">-/-</option>
<option [ngValue]="subcategory" *ngFor="let subcategory of subCategories">{{subcategory.title}}</option>
</select>
</div>
</div>
If I need to post typescript code please tell me, but Here I got values from database, and this is only problem for me, how to filter Subcategory based on Category selection.
Thanks guys Cheers!