I have a custom component
import { Component, OnInit } from "@angular/core";
import { EmploymentType } from './employmenttype.model';
import { EmploymentTypeService } from "../employmenttype/employmenttype.service";
@Component({
selector: 'employmenttype-dropdown',
templateUrl: 'employmenttype-dropdown.html'
})
export class EmploymentTypeDropdownComponent implements OnInit {
selectedEmploymentType:EmploymentType = new EmploymentType('None',0,0);
employmentTypes = [];
constructor(private employmentTypeService: EmploymentTypeService){
}
ngOnInit() {
this.employmentTypeService.getEmploymentTypes()
.subscribe(
(employmentTypes: EmploymentType[]) => {
this.employmentTypes = employmentTypes;
}
);
}
}
and here is the template
<select class="form-control" required="required" name="employment-type">
<option *ngFor="let employmenttype of employmentTypes" value={{employmenttype.id}}>
{{employmenttype.name}}
</option>
</select>
I want to use it in the parent component like this:
<employmenttype-dropdown ([ngModel])="employee?.employmentType" ></employmenttype-dropdown>
but it does not work. Please help