I added new scripts to my .angular-cli.json file like this:
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"styles.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/popper.js/dist/popper.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
]
Then I added carousel from bootstrap to my app.component.html file like that (just copy from documentation):
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel" style="background: #000000;">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="https://ocdn.eu/pulscms-transforms/1/jQxktkpTURBXy83MjQ2M2M3NjAzZmU5MTA0MTZjOWJiYzVlY2U0NzUzNy5wbmeRkwLNAyYA" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://ocdn.eu/pulscms-transforms/1/jQxktkpTURBXy83MjQ2M2M3NjAzZmU5MTA0MTZjOWJiYzVlY2U0NzUzNy5wbmeRkwLNAyYA" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://ocdn.eu/pulscms-transforms/1/jQxktkpTURBXy83MjQ2M2M3NjAzZmU5MTA0MTZjOWJiYzVlY2U0NzUzNy5wbmeRkwLNAyYA" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" 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="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
When I try load scripts from my index.html file like that (everything works):
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
</head>
<body>
<app-root></app-root>
</body>
</html>
Is there any solution? I make build by ng build, restar ng serve and it didn't help.
I had a similar issue with an angular-cli app. I finally discovered that my index.html
was missing an include:
<script type="text/javascript" src="scripts.bundle.js">
Adding that script include fixed it for me.
FYI my server setup doesn't use the generated index.html
... I probably copied and pasted the index.html
script includes and then added the scripts section later leading to the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With