Reputation: 177
I set up a new project using "ng new xxx", just add one line in index.html:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bbb</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
<script type="text/javascript" src="./CitrixHTML5SDK.js"></script>
</body>
</html>
Then put the JS file in the same dir as index.html
But when I run "ng server", the browser always show: 404
Does anyone know why? Thanks in advance.
Upvotes: 1
Views: 651
Reputation: 1369
If you want to create a new folder i.e. "data". Then you will have to add "data" in "assets" array of angular-cli.json file. See below JSON data :-
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"data",
"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": [
"styles.css"
],
"scripts": ["data/sample.js"],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
After that don't forget to restart the server. Otherwise you will get 404 error.
Upvotes: 0
Reputation: 7749
I was going through same issue with JSON file, so what I done is kept my JSON file in to assets
folder. And access it through my code.
Here in Project file review you can also verify it.
Upvotes: 1