2017-02-16 12 views
1

私はng2-admin templateを使用しており、PrimeNGを追加しようとしていますが、追加するのは苦労しています。私はPrimeNGを含めるようにテンプレートで行った変更以下Angular 2 WebpackアプリにPrimeNGを含めることができません

./src/vendor.browser.ts:

// Prime faces: http://www.primefaces.org/primeng/#/setup 
import 'primeng/primeng'; 

./src/app/app.module.ts:

import { ToggleButtonModule } from 'primeng/primeng'; 

@NgModule({ 
    bootstrap: [App], 
    declarations: [ 
    App 
    ], 
    imports: [ // import Angular's modules 
    ... 
    ... 
    ... 
    ToggleButtonModule 
    ], 
    providers: [ // expose our Services and Providers into Angular's dependency injection 
    ENV_PROVIDERS, 
    APP_PROVIDERS 
    ] 
}) 

./src/app/pages/dashboard/dashboard.component.ts:

import { ToggleButtonModule } from 'primeng/primeng'; 

./src/app/pages/dashboard/dashboard.html:

<p-toggleButton [(ngModel)]="checked"></p-toggleButton> 

私は次のエラー取得しています:私はngModelを削除した場合

Can't bind to 'ngModel' since it isn't a known property of 'p-toggleButton'.

  1. If 'p-toggleButton' is an Angular component and it has 'ngModel' input, then verify that it is part of this module.
  2. If 'p-toggleButton' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.

をタグから次のエラーが表示されます。

'p-toggleButton' is not a known element:

  1. If 'p-toggleButton' is an Angular component, then verify that it is part of this module.
  2. If 'p-toggleButton' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.

Angular 2-WebpackアプリでPrimeNGを統合する正しい方法は何ですか?私はここで何が欠けているのですか?

答えて

0

私はまだPrimeNGを使用していませんが、それを検討しています。

しかし、あなたの問題は解決するのが簡単だと思います。 ngModelは、角度FormsModuleに由来します。彼らの文書は、この依存関係をより明確にすることができます。

これをあなたのNgModuleに追加してください。

import { FormsModule } from '@angular/forms'; 

@NgModule({ 
    imports: [ 
    ... 
    FormsModule 
    ], 
    ... 
}); 
関連する問題