我有一个 angular4 和 Universal 应用程序,带有 aapp.module
和 a app.browser.module/app.server.module
。
App.Module
具有所有应用程序配置和引导程序。app.browser.module
调用浏览器中使用的模块,以避免破坏通用构建。
当我将外部库 ( ng2-semantic-ui
) 导入app.browser.module
时,应用程序无法识别ng2-semantic-ui
指令,但当我将其导入“app.module”时,它会识别。
这是我的模块结构:
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import { SuiModule } from 'ng2-semantic-ui';
@NgModule({
declarations: [
AppComponent,
HomeComponent,
],
imports: [
BrowserModule.withServerTransition({appId: 'app.id'}),
SuiModule,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
app.browser.module.ts
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppModule } from './app.module';
import { AppComponent } from './app.component';
import { SuiModule } from 'ng2-semantic-ui';
@NgModule({
imports: [
BrowserAnimationsModule,
AppModule,
SuiModule,
],
bootstrap: [AppComponent]
})
export class AppBrowserModule {}
SuiModule
当我在应用程序中导入app.module
时识别它的指令,但是当我把它拿出来时app.browser.module
,它不会。为什么?
错误
compiler.es5.js:1690 Uncaught Error: Template parse errors:
'sui-sidebar' is not a known element:
1. If 'sui-sidebar' is an Angular component, then verify that it is part of this module.
2. If 'sui-sidebar' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
当我将PSBrowserAnimationsModule
导入到应用程序中时,它们会在应用程序中被识别app.browser.module
。