Tutorial on using component in bootstrap in ng2 study notes
- 2021-08-03 08:22:09
- OfStack
Preface:
Now angular2 has been integrated with angular-cli. It is recommended that you can quickly develop ng2 projects based on this without building your own environment;
For related information, please go to: https://angular.cn/docs/ts/latest/cli-quickstart.html
Text:
Take the picture carousel component carousel as an example:
First, install ng2-bootstrap and bootstrap
npm install ng2-bootstrap bootstrap --save
Import in the required module
import { CarouselModule } from 'ng2-bootstrap'
@NgModule({
imports: [
CarouselModule.forRoot()
],
})
export class HeaderModule { }
Then, there is a very important point, don't forget to introduce the bootstroop. min. css file;
Next, write to the html of the component
<carousel [interval]="myInterval" [noWrap]="noWrapSlides" [(activeSlide)]="activeSlideIndex">
<slide *ngFor="let slidez of slides;">
<img [src]="slidez" >
</slide>
</carousel>