Getting error while using selector of one component in different component html file

10 views
Skip to first unread message

indarpreet singh sokhi

unread,
Jan 19, 2018, 2:23:10 AM1/19/18
to Angular and AngularJS discussion

Uncaught Error: Template parse errors:
'app-tree-view' is not a known element:
1. If 'app-tree-view' is an Angular component, then verify that it is part of this module.
2. If 'app-tree-view' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("


                                    [ERROR ->]<app-tree-view>
                                                            </app-tree-view>

Tried everything but not getting the solution any help here.

Arnaud Deman

unread,
Jan 19, 2018, 3:13:53 AM1/19/18
to Angular and AngularJS discussion
Hello,

I am not an Angular Guru but I try to help you.

If app-tree-view is the selector for an Angular component I would say that its entry is missing in the module of the component that is using it.
If you don't have written a module for AppTreeViewComponent and you want to use it, for instance  in your AppComponent component, I think you should add it in app.module.ts :

import {AppTreeViewComponent} from 'your/path/app-tree-view.component;

@NgModule({
  imports: [
     (...)
  ]
declarations: [
     (....)
     AppTreeViewComponent
]
(...)
})
export class AppModule {}
   

If AppTreeViewComponent belongs to its own module you should import the module instead :

import {AppTreeViewModule} from 'your/path/app-tree-view.module';

@NgModule({
    imports: [
     (...)
     AppTreeViewModule
    ],
(...)
})
export class AppModule {}


This import should be done in the app module if it is used in the whole application, otherwise you can add it only in the module that need it.

Regards,
Arnaud.
Reply all
Reply to author
Forward
0 new messages