【发布时间】:2017-06-29 01:21:18
【问题描述】:
我的 Angular 2 应用程序中有 2 个模块,它是使用 Angular-Cli 创建的。 (版本 1.0.0-beta.28.3) 软件包由“npm install ng2-bootstrap@latest bootstrap@latest --save”安装(不确定我是否遗漏了什么) ng2-bootstrap 和 bootstrap 包是最新版本。 当我在 app.module.ts 中导入 ng2-directive 时,一切正常。但是,我尝试在嵌套模块中使用它,没有出现任何内容。
明确地说:
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 上使用手风琴。 但是,当我尝试在 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 { }
我得到了白屏。
我不确定这是问题还是我的错误。
【问题讨论】:
-
你有什么错误吗?
-
不,控制台上一切正常
-
你也有路由吗?如果你在路由中启用跟踪,看看你是否有路由问题。
-
不,我在新应用中尝试过,app.component.html 中只有一行:'
标签: angular module ng2-bootstrap