Pad*_*ich 20 ng-bootstrap angular
我正在尝试将ng bootstrap UI集成到我的Angular 2项目中.按照此处的简单说明操作后: https://ng-bootstrap.github.io/#/getting-started使用任何ngb bootstrap标记时出现以下错误:
错误:没有NgbAlertConfig的提供者!
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { StocksComponent } from './stocks/stocks.component';
import { HighlightDirective } from './highlight.directive';
import { StockService } from './stock.service';
import { DateFormatterPipe } from './date-formatter.pipe'
import { routing } from './app.routing';
import { DashboardComponent } from './dashboard/dashboard.component'
import { CurrencyService } from './currency.service';
import { BondsDirective } from './bonds.directive';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
@NgModule({
declarations: [
AppComponent,
StocksComponent,
HighlightDirective,
DateFormatterPipe,
DashboardComponent,
BondsDirective
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
routing,
NgbModule
],
providers: [StockService, CurrencyService],
bootstrap: [AppComponent]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
}
Run Code Online (Sandbox Code Playgroud)
<ngb-alert>
Random Message
</ngb-alert>
Run Code Online (Sandbox Code Playgroud)
{
"project": {
"version": "1.0.0-beta.17",
"name": "my-prog-cli"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": "assets",
"index": "index.html",
"main": "main.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"mobile": false,
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.css",
"styles.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/tether/dist/js/tether.js",
"../node_modules/bootstrap/dist/js/bootstrap.js"
],
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"addons": [],
"packages": [],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"prefixInterfaces": false
}
}
Run Code Online (Sandbox Code Playgroud)
San*_*ket 41
在您的app.module.ts中导入NgbModule,如下所示 -
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
Run Code Online (Sandbox Code Playgroud)
并将其添加到ngmodule的导入部分 -
@NgModule({
declarations: [AppComponent, ...],
imports: [NgbModule.forRoot(), ...],
bootstrap: [AppComponent]
})
Run Code Online (Sandbox Code Playgroud)
看看这是否有帮助.
Dar*_*yne 12
对于其他任何正在为其他组件获取此错误的人,例如ngbDropdown
..确保您ngbDropdown
在父元素上设置了该集合.
归档时间: |
|
查看次数: |
15055 次 |
最近记录: |