Reputation: 252
I am creating a form where I have a dropdown list when user selects the option
Software developer
a new div is displayed , with two option
- App Developer
- Web Developer
I am giving code below -:
html code -
<div class="form-group">
<label for="dept"> Departmant </label>
<select id="dept" (change)="fun()" class="form-control" class="form-control" name="departmant" [(ngModel)]="departmant">
<option value="1"> HelpDesk </option>
<option value="2"> Hr</option>
<option value="3"> Software Engineer </option>
<option value="4"> System Admin </option>
</select>
</div>
<div class="form-group" *ngIf="doninSe">
<label for="domin"> Domain: </label>
<select id="domin" class="form-control" name="domin" [(ngModel)]="domin">
<option *ngFor="let domins of Domin"> {{domins.name}} </option>
</select>
</div>
ts code -:
export class CreateEmployeeComponent implements OnInit {
DominSe: boolean = True ;
constructor() { }
Domin: Departmants[] =
[{id: 1 , name: 'App Developer' },
{id: 2 , name: 'Web Developer'},
];
ngOnInit() {
}
}
Also I am getting error while defining DomineSe variable
DominSe: boolean = True ;
getting error -:
[ts] Cannot find name 'True'.
any
Upvotes: 0
Views: 35
Reputation: 4145
boolean value should be true not True
and also use the same variable name in html as you declared in .ts
here's is example
<div class="form-group" *ngIf="dominSe">
<label for="domin"> Domain: </label>
<select id="domin" class="form-control" name="domin" [(ngModel)]="domin">
<option *ngFor="let domins of Domin"> {{domins.name}} </option>
</select>
</div>
and in .ts
dominSe: boolean = true;
Upvotes: 0