Angular-cli: Uncaught Error: Template parse errors: 'component' is not a known element:

Created on 11 Dec 2017  路  3Comments  路  Source: angular/angular-cli

I am facing the problem in angular 4.4 , In my app, I have hierarchical view. In which I have created a:= module 1 -> module 2 -> my component.I have declared everything correctly. , But still I'm getting error.Declared聽component.Imported聽it into other module.selector聽name is same.Exported聽component in聽module 2.Imported聽module 2 in聽module 1.

What could be the catch?聽Component Code: Admin -> Configuration -> mycomponent //My component

My Code:=>

Component Code:
Admin -> Configuration -> mycomponent
//My component
import { Component, OnInit, ViewChild, ChangeDetectorRef } from '@angular/core';
@Component({
selector: 'test-mycomponent',
templateUrl: './mycomponent.component.html',
styleUrls: ['./mycomponent.component.scss']
})
export class MyComponentComponent implements OnInit {
@ViewChild('myComponentTable')

constructor() {
}
ngOnInit() {
//init functionality
}
}

// configure module code
import { NgModule,Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { MyComponentComponent } from './mycomponent/mycomponent.component';
@NgModule({
imports: [
CommonModule,
WidgetsModule,
FormsModule,
NgbModule
],
declarations: [
MyComponent
],
providers: [
],
exports: [
MyComponent
]
})
export class ConfigurationModule { }

//Main module admin
import { NgModule, Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ConfigurationModule } from './configuration/configuration.module';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { MyComponentComponent } from './configuration/mycomponent/mycomponent.component';
import { FormsModule } from '@angular/forms';
@NgModule({
imports: [
CommonModule,
NgbModule,
FormsModule,
ConfigurationModule
],
declarations: [
],
exports: [
]
})
export class AdminModule { }

and I am calling that template in another file
//Test file html


Most helpful comment

I think that the implementation code contains errors.
You can see a simple example on how to implement the use of an Angular component at this post:
https://expertcodeblog.wordpress.com/2018/01/09/how-to-resolve-uncaught-error-template-parse-errors-mycomponent-selector-name-is-not-a-known-element-on-angular/

All 3 comments

This issue is a support issue and not a bug or issue with the CLI itself. I suggest submitting your question where you can can some support/assistance such as StackOverflow.
Closing this issue.

I think that the implementation code contains errors.
You can see a simple example on how to implement the use of an Angular component at this post:
https://expertcodeblog.wordpress.com/2018/01/09/how-to-resolve-uncaught-error-template-parse-errors-mycomponent-selector-name-is-not-a-known-element-on-angular/

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings