angular 使用 ng-bootstrap

文档及代码:

https://ng-bootstrap.github.io

 

安装:

npm install --save @ng-bootstrap/ng-bootstrap

在appmodule引入

import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
@NgModule({
  declarations: [AppComponent, ...],
  imports: [NgbModule.forRoot(), ...], // NgbModule.forRoot() 为新增内容
  bootstrap: [AppComponent]
})
export class AppModule {
}

引入css

下载bootstrap并引入css文件

https://www.getbootstrap.com/

把bootstrap.min.css放入assets文件加下

然后再style.css中添加:

@import 'assets/bootstrap.min.css';

 

使用

<ngb-alert type="success" [dismissible]="true">
    <strong>Success!</strong> Good work.
</ngb-alert>

 

文档参考:

https://ng-bootstrap.github.io/#/components

发表评论