1

I have my index.html:

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>Aerosmith Messenger</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" 
rel="stylesheet" />
  <link rel="icon" type="image/x-icon" href="favicon.ico" />
  <link rel="stylesheet" href="assets/spinner.css" />

  <!--<script src="src/scripts/jquery-1.6.4.js"></script>-->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.js">

</script>
</head>
<body>
  <am-root>
    <div class="spinner">
      <div class="double-bounce1"></div>
      <div class="double-bounce2"></div>
    </div>
  </am-root>
</body>
</html>

I'm trying to include jquery script. And it does not work when i include it like this (commented line). Help me resolve this issue because i need to include some other scripts. By "does not work" i mean all the time that commented script is not found in console of a browser.

7
  • 2
    where is your jquery-1.6.4.js file in your directory? and where is your index.html located? Commented Jun 30, 2017 at 6:11
  • index.html in src, jquery - src/scripts Commented Jun 30, 2017 at 6:13
  • so you should include your jquery library like: <script src="./scripts/jquery-1.6.4.js"></script> or <script src="scripts/jquery-1.6.4.js"></script> Commented Jun 30, 2017 at 6:14
  • GET localhost:4200/scripts/jquery-1.6.4.js (not found) Commented Jun 30, 2017 at 6:16
  • if you go to localhost:4200/src/scripts/jquery-1.6.4.js in your browser it finds the file? Commented Jun 30, 2017 at 6:17

3 Answers 3

2

Make sure you provide the path of "jquery-1.6.4.js" exactly where it is located. Check the src/scripts. And if it is there then you should include it somewhat like this, "~/src/scripts/jquery-1.6.4.js". Assuming you have "src" folder in which "script" folder exists, which has your jquery file.

Sign up to request clarification or add additional context in comments.

7 Comments

in which folder you have the jquery file/
[project name]/src/scripts
so try including it like "~/src/scripts/jquery-1.6.4.js"
still not found
try to put the js file in the root of your project directory. I mean projectName/jquery-1.6.4.js and then see if it finds it.
|
1

Try add script and style to angular-cli.json in root project, as follows:

"apps": [{
    ...
    ... 
    "styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.min.css",
        "../node_modules/font-awesome/css/font-awesome.min.css",
        "./styles.css"
    ],
    "scripts": [
        "assets/js/jquery.js",
        "../node_modules/bootstrap/dist/js/bootstrap.min.js",
        "assets/js/custom.js"
    ],

3 Comments

i've already tried it - still not found "scripts": [ "../node_modules/jquery/dist/jquery.js" ],
Check angular-cli.json file Carefully. First, make sure you install the modules by angular-cli
Unfortunately none of these answers solved my problem
1

Latest version of angular-cli(angular-cli: 1.0.0-beta.19-3) provides an assets folder under src directory. You just need to add src property of an image tag as below,

   <img src="./assets/logo.png">

But as turns out i ditn't need to include any scripts to my index.html. The main problem was that sometimes my project didn't detect the changes. I mean - in past i added line to include jquery on index.html, my project didn't detect it and therefore browser didn't show any errors (not found) and after that all the time i thoutht that i was working with jquery because of that included jquery on index.html. But actually jquery was working because i also included it in different way. So be careful about it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.