primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Can't bind to 'value' since it isn't a known property of 'p-tree'. TreeNode' only refers to a type, but is being used as a value here

Open nisarahmedah opened this issue 9 years ago • 7 comments

I'm submitting a ... (check one with "x")

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Current behavior The following error as seen in the browser console: **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.**

I have imports statement for: import { TreeNode } from 'primeng/primeng';

Strangely when I place TreeNode under @NgModule({ imports: [BrowserModule, FormsModule, HttpModule, TreeNode, . . ] I see the following error [from IDE Intellisense]: [ts] 'TreeNode' only refers to a type, but is being used as a value here.

Then I looked at this issue which is one year old and tried to import the TreeNode as follows in the app.module.ts. Still the issue is at large: import { TreeNode } from 'primeng/components/common/api';

Expected behavior Be able to use Tree functionality

Please tell us about your environment: MacOS Darwin

  • Angular version: 2.4.0

  • PrimeNG version: 2.0.3

  • Browser: [Chrome]

  • Language: [all | TypeScript 2.0.2 | ES6/7 | ES5]

nisarahmedah avatar Mar 25 '17 11:03 nisarahmedah

@ahmni01

Try to import this in you app.module.ts "import {TreeModule,TreeNode} from 'primeng/primeng';"

sourabh8003 avatar Mar 25 '17 14:03 sourabh8003

@sourabh8003 - I have those import statements.

nisarahmedah avatar Mar 25 '17 15:03 nisarahmedah

@ahmni01 can you share code of app.module.ts or wherever you imported the required module for tree component.

sourabh8003 avatar Mar 25 '17 15:03 sourabh8003

@sourabh8003 - Sure, here it is: app.module.ts import { NgModule, APP_INITIALIZER } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { routing } from './app.routing'; import { Http, HttpModule } from '@angular/http'; import { FormsModule } from '@angular/forms';

import { InputTextModule } from 'primeng/primeng'; import { ChartModule } from 'primeng/primeng'; import { CalendarModule } from 'primeng/primeng'; import { DataTableModule } from 'primeng/primeng'; import { ButtonModule } from 'primeng/primeng'; import { MessagesModule } from 'primeng/primeng'; import { ConfirmDialogModule, ConfirmationService } from 'primeng/primeng'; import { DialogModule } from 'primeng/primeng'; import { SelectButtonModule } from 'primeng/primeng'; import { AutoCompleteModule } from 'primeng/primeng'; import { SharedModule } from 'primeng/primeng'; import { AccordionModule } from 'primeng/primeng'; import { ToolbarModule } from 'primeng/primeng'; import { PanelModule } from 'primeng/primeng'; import { FieldsetModule } from 'primeng/primeng'; import { TooltipModule } from 'primeng/primeng'; import { TreeTableModule } from 'primeng/primeng'; import { TreeNode } from 'primeng/primeng';

import { AppComponent } from './app.component'; import { LoginComponent } from './login/login.component'; import { AuthService } from './services/auth.service'; import { SessionService } from './services/session.service'; import { SessionUtilService } from './services/session.util.service'; import { ConfigService } from './services/config.service'; import { AdminGuard } from './services/admin.service'; import { UserRoleService } from './services/user.role.service'; import { AdminComponent } from './admin/admin.component'; import { AdminDetailComponent } from './admin/admin-detail.component'; import { ChatService } from './services/chat.service'; import { TreeNodeService } from './services/tree.node.service';

@NgModule({ imports: [BrowserModule, FormsModule, HttpModule, routing, InputTextModule, ChartModule, CalendarModule, DataTableModule, ButtonModule, MessagesModule, ConfirmDialogModule, DialogModule, SelectButtonModule, AutoCompleteModule, SharedModule, AccordionModule, ToolbarModule, PanelModule, FieldsetModule, TooltipModule, TreeNode, TreeTableModule ], declarations: [ AppComponent, LoginComponent, AdminComponent, AdminDetailComponent ], providers: [ AuthService, SessionService, SessionUtilService, ConfirmationService, AdminGuard, UserRoleService, ChatService, TreeNodeService, ConfigService, { provide: APP_INITIALIZER, useFactory: (config: ConfigService) => () => config.load(), deps: [ConfigService], multi: true } ], bootstrap: [AppComponent] }) export class AppModule {}

nisarahmedah avatar Mar 26 '17 04:03 nisarahmedah

@ahmni01
Step 1> import the TreeModule in your app module : import {TreeModule} from 'primeng/primeng'; Step 2> remove TreeNode import statement from { import { TreeNode } from 'primeng/primeng'; } app.module.ts and import it at your component file where you want to use the 'p-tree' component. it should work.

Issue: you are using an p-tree selector but you haven't import the module for p-tree and the second issue is TreeNode is a type not a module so remove all appearance of TreeNode from app.module.ts and add it in your component where you are using tree feature. it should work.

sourabh8003 avatar Mar 26 '17 06:03 sourabh8003

Please use forum for these types of cases as it is an issue with your config.

cagataycivici avatar Mar 27 '17 16:03 cagataycivici

I have the same problem,so how did you debug?

yxmanyxman avatar Jul 05 '17 07:07 yxmanyxman