I am pretty new to Angular, so this may seem like a stupid question. But I was able to find little information regarding my issue from internet.
I have been trying to include some JavaScript code into an angular html template. But due to some reason, it is not getting executed.
I am also trying to load some js files into the template in order to execute some features in the views. I included these files in the root index.html and also inside the template file, but the required function in the template did not catch the codes from these js files. I am confused what I should do additionally here.
Please verify the codes below.
project.template.html
<div>
// all the necessary view items
</div>
<script src="../../vendor.js"></script>
<script src="../../plugins.js"></script>
<script src="../../main.js"></script>
<script type="text/javascript">
$(function() {
alert('hi');
});
</script>
<router-outlet></router-outlet>
index.html
<!DOCTYPE html>
<html>
<head>
<base href="/">
<title>Title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/app/main.css">
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
<script src="vendor.js"></script>
<script src="plugins.js"></script>
<script src="main.js"></script>
</head>
<body>
<my-app>Loading...</my-app>
</body>
</html>
There are no errors in the console. Also, I see the JS files are loaded into the view from the Chrome developer tools. But they are not invoked.
Please let me know if any more code is required.