2016-07-21 6 views
6

私のアプリには、PrimeNG & Angular2が使用されています。Angular2/PrimeNG - カント表示ドロップダウン

私には、選択可能なテーマのドロップダウンメニューが表示されるはずのコンポーネントがあります。 私はPrimeNG Dropdownのドキュメンテーションを辿ってきましたが、私が見る限り、すべてが同じように構築されています。

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> 

任意のアイデアしかし、私は常にエラー " '' なし値アクセサに"

theme.component.tsを取得しています問題はありますか? :( 編集:問題のactuallyyはngModelである私はhtmlタグから削除する場合はドロップダウンが表示されます

答えて

2

多くの同様の問題があります

もあなただけmodelであなたのngModelを変更して、エラーメッセージを回避することができますが、処理されているprimengと現在の問題があります。

また、depractedフォームを使用して無効にしてください。

import { disableDeprecatedForms, provideForms } from '@angular/forms'; 

bootstrap(AppComponent, [ 
disableDeprecatedForms(), 
provideForms()]); 

更新

はprimeng問題の当局者によると、こちらをご覧解決されました。

0

多くの同様の問題があり、ここを見てそこに持っている

https://github.com/primefaces/primeng/issues/549 ngModel:私は同じコンソールのエラーを得ている ''

なし値アクセサ、 ちょうど追加[ngModelOptions] = "{standalone:true}はOKです

関連する問題