Reputation: 2365
I have an app served on localhost:4200
with ng serve
.
When I hit localhost:4200/home
, everything works fine.
When I hit localhost:4200/vehicle/idKind/id
, Chrome tries to load localhost:4200/vehicle/idKind/runtime.js
, which results in a 404 error.
After inspecting the index.html
generated by angular cli, I noticed the script tags are generated before the html tag :
<script src="runtime.js" type="module"></script><script src="polyfills.js" type="module"></script><script src="styles.js" type="module"></script><script src="scripts.js" defer></script><script src="vendor.js" type="module"></script><script src="main.js" type="module"></script><script src="runtime.js" type="module"></script><script src="polyfills.js" type="module"></script><script src="styles.js" type="module"></script><script src="scripts.js" defer></script><script src="vendor.js" type="module"></script><script src="main.js" type="module"></script>
<!doctype html>
<html lang="fr">
<head>
<base href="/">
<!-- some scripts, stylesheets and fonts -->
<title>My app</title>
</head>
<app-root></app-root>
</html>
When I place them manually after the <head>
(and the <base href="/" />
) Chrome tries to load localhost:4200/runtime.js
, which is the behaviour I want.
My src/index.html
:
<!doctype html>
<html lang="fr">
<head>
<base href="/">
<!-- some scripts, stylesheets and fonts -->
<title>My app</title>
</head>
<app-root></app-root>
</html>
Why are my scripts tags generated before html?
Upvotes: 1
Views: 782
Reputation: 126
you probably need to check if app-root selector is written inside body like this in index.html
<body>
<app-root></app-root>
</body>
Upvotes: 4