首页 文章

Angular2 / PrimeNG - 无法显示下拉列表

提问于
浏览
7

我正在为我的应用程序使用PrimeNG和Angular2 .

我've got a component which should show a dropdown menu of selectable themes. I'已经跟着PrimeNG Dropdown文档,据我所知我've got everything build up the same way. But I'我总是得到错误"No value accessor 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>

任何可能出现问题的想法? :(编辑:问题实际上是ngModel . 如果我从html标签中删除它,将显示Dropdown .

2 回答

相关问题