Angular2 / PrimeNG - Cant window opens

I am using PrimeNG and Angular2 for my application.

I have a component that should display a dropdown menu of selected topics. I followed PrimeNG Dropdown's documentation, and as far as I can see, everything works out the same way. But I always get the error "No data access for" "

theme.component.ts:

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() { } } 

theme.component.html:

 <p-dropdown [options]="selectables" [(ngModel)]="style"></p-dropdown> 

Any ideas where a problem might arise? :( Edit: the problem is actually ngModel. A popup will be displayed if I remove it from the html tag.

+6
source share
2 answers

There are many similar problems that exist here.

you can also avoid the error message by simply changing ngModel to model , but there is a current issue with primeng that is being processed.

try using disabled forms.

 import { disableDeprecatedForms, provideForms } from '@angular/forms'; bootstrap(AppComponent, [ disableDeprecatedForms(), provideForms()]); 

Update

according to officials primeng problems have been resolved here.

+2
source

There are many similar problems that exist here.

https://github.com/primefaces/primeng/issues/549 ngModel: no data access for ''

I got the same console error, just add [ngModelOptions] = "{standalone: ​​true} in order

0
source

All Articles