As I work on my app using PrimeNG and Angular2, I encountered a challenge with a component that is supposed to display a dropdown menu of selectable themes. Despite following the guidelines in the PrimeNG Dropdown documentation closely, I keep receiving an error message stating "No value accessor for ''."
In my theme.component.ts file:
import { Component, OnInit, Input } from '@angular/core'
import { Dropdown, SelectItem} from 'primeng/primeng';
@Component({
selector: 'my-themes',
templateUrl: 'dist/html/theme.component.html',
directives: [Dropdown],
})
export class ThemeComponent {
selectables: SelectItem[];
style: string;
constructor() {
this.selectables = [];
this.selectables.push({ label: 'Nightflat', value: 'Nightflat' });
this.selectables.push({ label: 'Flat', value: 'Flat' });
}
ngOnInit() {
}
}
The content of theme.component.html looks like this:
<p-dropdown [options]="selectables" [(ngModel)]="style"></p-dropdown>
Could you suggest where the issue might lie? Upon closer inspection, it seems that the problem lies with ngModel. Interestingly, the Dropdown appears when I remove it from the html tag.