`<div >
<div >
<wcs-select [(ngModel)]="SelectedSerie" placeholder="Série" id="leselectg">
<ng-container *ngFor="let serie of series">
<wcs-select-option *ngIf="serie.type_serie == 'Série'" >
{{ serie.code_serie_materiel }}
</wcs-select-option>
</ng-container>
</wcs-select>
<p>Selected option: {{ SelectedSerie }}</p>
</div>
<div >
<wcs-select placeholder="Sous-série" id="leselectg">
<ng-container *ngFor="let serie of series">
<wcs-select-option *ngIf="serie.type_serie == 'Sous-Série' && serie.code_serie_materiel.startsWith(SelectedSerie)">
{{ serie.code_serie_materiel }}
{{ serie.type_serie }}
</wcs-select-option>
</ng-container>
</wcs-select>
</div>
<div >
<wcs-select placeholder="Variantes" id="leselectg">
<ng-container *ngFor="let serie of series">
<wcs-select-option *ngIf="serie.type_serie == 'Variante'">
{{ serie.code_serie_materiel }}
{{ serie.type_serie }}
</wcs-select-option>
</ng-container>
</wcs-select>
</div>
</div>
I am trying to include a Selected Series variable in the parameters of my startsWith however it only works when I include a hard string, is there another way to include a variable?
CodePudding user response:
You can use string template literals, here is example:
const tmp = 'test';
console.log('testing string'.startsWith(`${tmp}`));