I'm currently working on a angular 4 project, and i'm using angular cli.
Currently i'm using perfect scrollbar, bootstrap-slider.min.js, d3.js etc which is bundled together.
Problem When we add the script file inside the angular-cli scripts array, it is bundled together, and shown in the browser as script.bundle.js.
Now in script.js file we initialize the prefect scrollbar, but this does not work at all when the page is loaded.
I tried another way was placing the code inside the document ready function, the again ng served and refreshed the page and it worked. But when changed the route and again came back to the same view, it did not worked now, again i have to refresh it to make it work.
I feel once the script code is bundled it is not working, Do you have any solution for this problem.
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"../node_modules/perfect-scrollbar/dist/css/perfect-scrollbar.min.css",
"styles.css" ], "scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js",
"../node_modules/perfect-scrollbar/dist/js/perfect-scrollbar.jquery.min.js",
"../node_modules/d3/build/d3.min.js",
"script.js" ],
**Script.js**
/******* initializes custom scrollbars on elements *******/
$(".perfect-scrollbar").each(function() {
$(this).initCustomScrollbar();
});
(function($) {
$.fn.initCustomScrollbar = function() {
$(this).perfectScrollbar();
};
})(jQuery);
/******* initializes custom scrollbars on elements *******/
(function($) {
$.fn.initCustomScrollbar = function() {
$(this).perfectScrollbar();
};
})(jQuery);