angular5 ng-bootstrap和ngx-bootstrap區別


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">

還需要再引入 theme
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/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
 



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM