私はAngular2 WebアプリケーションでPrimeNGを使用しています。 私はapp.moduleでTreeModuleをインポート:PrimeNG p-treeエラー: 'p-tree'の既知のプロパティではないため 'value'にバインドできません
import { TreeModule } from 'primeng/primeng';
@NgModule({
imports: [
TreeModule,
...
]
})
私のコンポーネントは次のとおりです。HTMLで
import { TreeNode } from 'primeng/primeng';
...
export class MyComponent implements OnInit {
treeNode: TreeNode[];
ngOnInit() {
//Simple value for test p-tree
this.treeNode = [
{
"label": "Documents: " + this.doc,
},
{
"label": "Documents: " + this.doc,
"children": [{
"label": "Work",
},
{
"label": "Home",
}]
}
]
}
}
そして最後に:
<p-tree [value]="treeNode"></p-tree>
エラーは次のとおりです。
zone.js:569 Unhandled Promise rejection: Template parse errors:
Can't bind to 'value' since it isn't a known property of 'p-tree'.
1. If 'p-tree' is an Angular component and it has 'value' input, then verify that it is part of this module.
2. If 'p-tree' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. (<p-tree [ERROR ->][value]="treeNode"></p-tree>)
'p-tree' is not a known element:
1. If 'p-tree' is an Angular component, then verify that it is part of this module.
2. If 'p-tree' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. (
[ERROR ->]<p-tree [value]="treeNode"></p-tree>
)
Task: Promise.then ; Value: Error: Template parse errors:
Can't bind to 'value' since it isn't a known property of 'p-tree'.
1. If 'p-tree' is an Angular component and it has 'value' input, then verify that it is part of this module.
2. If 'p-tree' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. (<p-tree [ERROR ->][value]="treeNode"></p-tree>)
私は似たようだ私は良い解決策を見つけることができませんでした。 私を助けることができますか? 非常にありがとう。
は、私は右のファイルにインポートを動かす解決
を解決しました。私のアプリはモジュールをインポートするためのカスタムファイルを持っているので、app.moduleファイルではなくimportをここに置く必要があります。
回答として独自の解決策を作成し、それを受け入れることができます。これは混乱を避けるでしょう。 – TimeTraveler