我有2个模块在我的angular 2应用程序中,它是用Angular-Cli创建的。(版本1.0.0-beta.28.3)包是由npm install ng2- bootstrap @latest --save安装的(不确定我是否遗漏了什么) ng2-bootstrap和bootstrap包是最新版本。当我在app.module.ts中导入ng2指令时,一切工作正常。但是,我尝试在嵌套模块中使用它,什么也没有出现。
明确地说:
import { InModule } from './in.module';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AccordionModule } from 'ng2-bootstrap';
import { AppComponent } from './app.component';
import { CompComponent } from './comp/comp.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
InModule,
HttpModule,
AccordionModule.forRoot()
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }我可以在appcomponent上使用accordions。但是,当我尝试在CompComponent中像下面这样使用它时:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AlertModule } from 'ng2-bootstrap';
import { CompComponent } from './comp/comp.component';
@NgModule({
declarations: [
CompComponent
],
imports: [
BrowserModule,
FormsModule,
AlertModule.forRoot() // or just AlertModule
],
providers: [],
bootstrap: []
})
export class InModule { }我看到白屏了。
我不确定这是一个问题还是我的错误。
发布于 2017-02-12 00:11:59
你把bootstrap css添加到angular-cli.json中了吗?您仍然需要加载css
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css"
],https://stackoverflow.com/questions/42163700
复制相似问题