码迷,mamicode.com
首页 > 其他好文 > 详细

angular5 ng-bootstrap和ngx-bootstrap区别

时间:2017-12-06 20:14:50      阅读:503      评论:0      收藏:0      [点我收藏+]

标签:images   ash   color   boot   one   module   link   pcdn   bootstra   

https://angular.cn/resources

ngx-bootstrap

 安装:

npm install ngx-bootstrap --save

再引入css
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet">

使用方法

一、module文件中引入模块


import { PaginationModule } from ‘ngx-bootstrap/pagination‘;

@NgModule({
  imports: [PaginationModule.forRoot(),...]
})
export class AppModule(){}

二、在在component中使用
<pagination [boundaryLinks]="true" [totalItems]="infoList.total_num" (pageChange)="pageChange($event)" [(ngModel)]="pageNo" class="pagination-sm"
previousText="上一页" nextText="下一页" firstText="第一页" lastText="最后一页">

</pagination>

ng-bootstrap
安装:

npm install --save @ng-bootstrap/ng-bootstrap
再引入css
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet">

使用方法:

一、module文件中引入模块
import {NgbModule} from ‘@ng-bootstrap/ng-bootstrap‘;

@NgModule({
  declarations: [AppComponent, ...],
  imports: [NgbModule.forRoot(), ...],
  bootstrap: [AppComponent]
})
二、在在component中使用
<ngb-pagination class="d-inline-block" (pageChange)="pageChange($event)" [collectionSize]="infoList.total_num"
[(page)]="pageNo" aria-label="Default pagination" [maxSize]="5"
[boundaryLinks]="true">
</ngb-pagination>


技术分享图片

 



总结,ng-bootstrap 以需要引入ngbModule,任何组件,如分页,tab,datapicker......都可以使用了,
但是ngx-bootstrap必须使用哪个组件就引入哪个组件

个人推荐使用ngx-bootstrap
 


angular5 ng-bootstrap和ngx-bootstrap区别

标签:images   ash   color   boot   one   module   link   pcdn   bootstra   

原文地址:http://www.cnblogs.com/mttcug/p/7994066.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!