问题描述
这是我的代码:
import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { LanguageTranslationModule } from './shared/modules/language-translation/language-translation.module'
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AuthGuard } from './shared';
import { SidebarComponent } from './layout/components/sidebar/sidebar.component';
import { HeaderComponent } from './layout/components/header/header.component';
@NgModule({
imports: [
CommonModule,
BrowserAnimationsModule,
HttpClientModule,
LanguageTranslationModule,
AppRoutingModule
],
declarations: [AppComponent,HeaderComponent,SidebarComponent],
providers: [AuthGuard],
bootstrap: [AppComponent],
exports: [
HeaderComponent,
SidebarComponent
],
})
export class AppModule {}
我不明白为什么得到这个惊喜:
I don't why I obtain this excepion:
在以后的模块中,我将导入CommonModule
而不是BrowerModule
.有人可以帮助我吗?
In the future module I import CommonModule
and not BrowerModule
. Anyone can help me?
推荐答案
仅将BrowserAnimationsModule
和HttpModule
导入一次(在您的根模块或核心模块中).
Import BrowserAnimationsModule
and HttpModule
only once (either in your root module or a core module).
仅一次导入这些提到的模块(仅在应用程序模块中):
import these mentioned modules only once(in app-module only):
BrowserModule
,BrowserAnimationsModule
,LazyLoadImageModule
(如果使用),CarouselModule
(如果使用),InfiniteScrollModule
(如果使用),HttpModule
(如果使用)
BrowserModule
, BrowserAnimationsModule
, LazyLoadImageModule
(if using it), CarouselModule
(if using it), InfiniteScrollModule
(if using it), HttpModule
( if using it)
这篇关于BrowserModule已加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!