Reputation: 554
I wrote a simple piece of html code with bootstrap carousel
<!--The content below is only a placeholder and can be replaced.-->
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</head>
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="http://10.23.129.132:1313/a.jpg" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="http://10.23.129.132:1313/b.jpg" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="http://10.23.129.132:1313/c.jpg" class="d-block w-100" alt="...">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<router-outlet></router-outlet>
If I run this as a simple html code, the carousel displays the image normally along with slider function but if I try to use Angular to compile, then only images are displayed. If I click on the slider button, it does not change the image. I inspected if the images are present, they are present and shows up if I hover over the links. Just the slider does not work.
This is angular.json file
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/popper.js/dist/umd/popper.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
]
This is app.module.ts
import { AlertModule } from 'ngx-bootstrap';
import {NgxPopperModule} from 'ngx-popper';
import { CarouselComponent } from 'ngx-bootstrap';
imports: [
NgxPopperModule,
CarouselComponent,
...
]
I do have all the components installed using npm.
Upvotes: 1
Views: 2072
Reputation: 15031
Don't use jQuery... instead go for valor-software.com/ngx-bootstrap/#/carousel
relevant HTML
<carousel>
<slide>
<img src="assets/images/nature/1.jpg" alt="first slide" style="display: block; width: 100%;">
</slide>
<slide>
<img src="assets/images/nature/2.jpg" alt="second slide" style="display: block; width: 100%;">
</slide>
<slide>
<img src="assets/images/nature/3.jpg" alt="third slide" style="display: block; width: 100%;">
</slide>
</carousel>
relevant TS
import { Component } from '@angular/core';
@Component({
selector: 'demo-carousel-basic',
templateUrl: './basic.html'
})
export class DemoCarouseBasicComponent {}
working sample from ngx-bootstrap site
Upvotes: 1