admin管理员组文章数量:1023815
I have an Angular application, but I am not understanding what the piler is telling me on why the application can't build. These are the errors that I'm getting from the piler:
ERROR in src/app/list-items/list-itemsponent.ts:9:14 -
error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
Is it missing an @NgModule annotation?
9 export class ListItemsComponent implements OnInit {
~~~~~~~~~~~~~~~~~~
src/app/not-found/not-foundponent.ts:8:14 - error NG6002: Appears in the NgModule.imports of AppModule, but could
not be resolved to an NgModule class.
Is it missing an @NgModule annotation?
8 export class NotFoundComponent implements OnInit {
~~~~~~~~~~~~~~~~~
This is my list-itemsponent.ts
file:
import { Component, OnInit, NgModule } from '@angular/core';
@Component({
selector: 'app-list-items',
templateUrl: './list-itemsponent.html',
styleUrls: ['./list-itemsponent.css']
})
export class ListItemsComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
This is my not-foundponent.ts
file:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-not-found',
templateUrl: './not-foundponent.html',
styleUrls: ['./not-foundponent.css']
})
export class NotFoundComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
Here is my app.module.ts
file:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './appponent';
import { HttpClientModule } from '@angular/mon/http';
import { ItemService } from './items.service';
import { NewItemFormComponent } from './new-item-form/new-item-formponent';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatButtonModule } from '@angular/material/button';
import { MatMenuModule } from '@angular/material/menu';
import { MatIconModule } from '@angular/material/icon';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { NavigationMenuComponent } from './navigation-menu/navigation-menuponent';
import { ListItemsComponent } from './list-items/list-itemsponent';
import { NotFoundComponent } from './not-found/not-foundponent';
import { BrowserModule } from '@angular/platform-browser';
const appRoutes: Routes = [ {
path: '', //default ponent to display
ponent: ListItemsComponent
}, {
path: 'addItem', //when items added
ponent: NewItemFormComponent
}, {
path: 'listItems', //when items listed
ponent: ListItemsComponent
}, {
path: '**', //when path cannot be found
ponent: NotFoundComponent
}
];
@NgModule({
declarations: [
AppComponent,
NewItemFormComponent,
NavigationMenuComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
MatFormFieldModule,
MatInputModule,
MatButtonModule,
MatIconModule,
MatMenuModule,
BrowserAnimationsModule,
FormsModule,
RouterModule.forRoot(appRoutes),
ListItemsComponent,
NotFoundComponent
],
providers: [ItemService],
bootstrap: [AppComponent]
})
export class AppModule { }
Does anyone happen to understand what the piler is trying to tell me about NgModule
?
I have an Angular application, but I am not understanding what the piler is telling me on why the application can't build. These are the errors that I'm getting from the piler:
ERROR in src/app/list-items/list-items.ponent.ts:9:14 -
error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
Is it missing an @NgModule annotation?
9 export class ListItemsComponent implements OnInit {
~~~~~~~~~~~~~~~~~~
src/app/not-found/not-found.ponent.ts:8:14 - error NG6002: Appears in the NgModule.imports of AppModule, but could
not be resolved to an NgModule class.
Is it missing an @NgModule annotation?
8 export class NotFoundComponent implements OnInit {
~~~~~~~~~~~~~~~~~
This is my list-items.ponent.ts
file:
import { Component, OnInit, NgModule } from '@angular/core';
@Component({
selector: 'app-list-items',
templateUrl: './list-items.ponent.html',
styleUrls: ['./list-items.ponent.css']
})
export class ListItemsComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
This is my not-found.ponent.ts
file:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-not-found',
templateUrl: './not-found.ponent.html',
styleUrls: ['./not-found.ponent.css']
})
export class NotFoundComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
Here is my app.module.ts
file:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.ponent';
import { HttpClientModule } from '@angular/mon/http';
import { ItemService } from './items.service';
import { NewItemFormComponent } from './new-item-form/new-item-form.ponent';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatButtonModule } from '@angular/material/button';
import { MatMenuModule } from '@angular/material/menu';
import { MatIconModule } from '@angular/material/icon';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { NavigationMenuComponent } from './navigation-menu/navigation-menu.ponent';
import { ListItemsComponent } from './list-items/list-items.ponent';
import { NotFoundComponent } from './not-found/not-found.ponent';
import { BrowserModule } from '@angular/platform-browser';
const appRoutes: Routes = [ {
path: '', //default ponent to display
ponent: ListItemsComponent
}, {
path: 'addItem', //when items added
ponent: NewItemFormComponent
}, {
path: 'listItems', //when items listed
ponent: ListItemsComponent
}, {
path: '**', //when path cannot be found
ponent: NotFoundComponent
}
];
@NgModule({
declarations: [
AppComponent,
NewItemFormComponent,
NavigationMenuComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
MatFormFieldModule,
MatInputModule,
MatButtonModule,
MatIconModule,
MatMenuModule,
BrowserAnimationsModule,
FormsModule,
RouterModule.forRoot(appRoutes),
ListItemsComponent,
NotFoundComponent
],
providers: [ItemService],
bootstrap: [AppComponent]
})
export class AppModule { }
Does anyone happen to understand what the piler is trying to tell me about NgModule
?
- Please share the code from your app.modules.ts the error is most likely there. – kacase Commented Apr 12, 2020 at 20:36
- Hi there, added above. – libracorn Commented Apr 12, 2020 at 20:41
1 Answer
Reset to default 4Remove both ponents from the imports section in your app.modules file and move them to declarations.
You are not creating a custom module; you are only creating a ponent. Import it the correct way and you should not have any more problems.
I also suggest you use the angular cli generator to generate new ponents.
ng generate ponent test
I have an Angular application, but I am not understanding what the piler is telling me on why the application can't build. These are the errors that I'm getting from the piler:
ERROR in src/app/list-items/list-itemsponent.ts:9:14 -
error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
Is it missing an @NgModule annotation?
9 export class ListItemsComponent implements OnInit {
~~~~~~~~~~~~~~~~~~
src/app/not-found/not-foundponent.ts:8:14 - error NG6002: Appears in the NgModule.imports of AppModule, but could
not be resolved to an NgModule class.
Is it missing an @NgModule annotation?
8 export class NotFoundComponent implements OnInit {
~~~~~~~~~~~~~~~~~
This is my list-itemsponent.ts
file:
import { Component, OnInit, NgModule } from '@angular/core';
@Component({
selector: 'app-list-items',
templateUrl: './list-itemsponent.html',
styleUrls: ['./list-itemsponent.css']
})
export class ListItemsComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
This is my not-foundponent.ts
file:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-not-found',
templateUrl: './not-foundponent.html',
styleUrls: ['./not-foundponent.css']
})
export class NotFoundComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
Here is my app.module.ts
file:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './appponent';
import { HttpClientModule } from '@angular/mon/http';
import { ItemService } from './items.service';
import { NewItemFormComponent } from './new-item-form/new-item-formponent';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatButtonModule } from '@angular/material/button';
import { MatMenuModule } from '@angular/material/menu';
import { MatIconModule } from '@angular/material/icon';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { NavigationMenuComponent } from './navigation-menu/navigation-menuponent';
import { ListItemsComponent } from './list-items/list-itemsponent';
import { NotFoundComponent } from './not-found/not-foundponent';
import { BrowserModule } from '@angular/platform-browser';
const appRoutes: Routes = [ {
path: '', //default ponent to display
ponent: ListItemsComponent
}, {
path: 'addItem', //when items added
ponent: NewItemFormComponent
}, {
path: 'listItems', //when items listed
ponent: ListItemsComponent
}, {
path: '**', //when path cannot be found
ponent: NotFoundComponent
}
];
@NgModule({
declarations: [
AppComponent,
NewItemFormComponent,
NavigationMenuComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
MatFormFieldModule,
MatInputModule,
MatButtonModule,
MatIconModule,
MatMenuModule,
BrowserAnimationsModule,
FormsModule,
RouterModule.forRoot(appRoutes),
ListItemsComponent,
NotFoundComponent
],
providers: [ItemService],
bootstrap: [AppComponent]
})
export class AppModule { }
Does anyone happen to understand what the piler is trying to tell me about NgModule
?
I have an Angular application, but I am not understanding what the piler is telling me on why the application can't build. These are the errors that I'm getting from the piler:
ERROR in src/app/list-items/list-items.ponent.ts:9:14 -
error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
Is it missing an @NgModule annotation?
9 export class ListItemsComponent implements OnInit {
~~~~~~~~~~~~~~~~~~
src/app/not-found/not-found.ponent.ts:8:14 - error NG6002: Appears in the NgModule.imports of AppModule, but could
not be resolved to an NgModule class.
Is it missing an @NgModule annotation?
8 export class NotFoundComponent implements OnInit {
~~~~~~~~~~~~~~~~~
This is my list-items.ponent.ts
file:
import { Component, OnInit, NgModule } from '@angular/core';
@Component({
selector: 'app-list-items',
templateUrl: './list-items.ponent.html',
styleUrls: ['./list-items.ponent.css']
})
export class ListItemsComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
This is my not-found.ponent.ts
file:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-not-found',
templateUrl: './not-found.ponent.html',
styleUrls: ['./not-found.ponent.css']
})
export class NotFoundComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
Here is my app.module.ts
file:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.ponent';
import { HttpClientModule } from '@angular/mon/http';
import { ItemService } from './items.service';
import { NewItemFormComponent } from './new-item-form/new-item-form.ponent';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatButtonModule } from '@angular/material/button';
import { MatMenuModule } from '@angular/material/menu';
import { MatIconModule } from '@angular/material/icon';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { NavigationMenuComponent } from './navigation-menu/navigation-menu.ponent';
import { ListItemsComponent } from './list-items/list-items.ponent';
import { NotFoundComponent } from './not-found/not-found.ponent';
import { BrowserModule } from '@angular/platform-browser';
const appRoutes: Routes = [ {
path: '', //default ponent to display
ponent: ListItemsComponent
}, {
path: 'addItem', //when items added
ponent: NewItemFormComponent
}, {
path: 'listItems', //when items listed
ponent: ListItemsComponent
}, {
path: '**', //when path cannot be found
ponent: NotFoundComponent
}
];
@NgModule({
declarations: [
AppComponent,
NewItemFormComponent,
NavigationMenuComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
MatFormFieldModule,
MatInputModule,
MatButtonModule,
MatIconModule,
MatMenuModule,
BrowserAnimationsModule,
FormsModule,
RouterModule.forRoot(appRoutes),
ListItemsComponent,
NotFoundComponent
],
providers: [ItemService],
bootstrap: [AppComponent]
})
export class AppModule { }
Does anyone happen to understand what the piler is trying to tell me about NgModule
?
- Please share the code from your app.modules.ts the error is most likely there. – kacase Commented Apr 12, 2020 at 20:36
- Hi there, added above. – libracorn Commented Apr 12, 2020 at 20:41
1 Answer
Reset to default 4Remove both ponents from the imports section in your app.modules file and move them to declarations.
You are not creating a custom module; you are only creating a ponent. Import it the correct way and you should not have any more problems.
I also suggest you use the angular cli generator to generate new ponents.
ng generate ponent test
本文标签: javascriptAngular application not building NgModuleStack Overflow
版权声明:本文标题:javascript - Angular application not building NgModule - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745588653a2157754.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论