0

I have successfully created angular custom element named in angular project and I want to use this custom element in another angular project I tried using following ways:

  • copied the profile.js file of custom element in another angular project and used in tag of another project in index.html

But getting error as GET http://localhost:4200/profile.js net::ERR_ABORTED 404 (Not Found)

Index.html

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

      <meta name="viewport" content="width=device-width, initial-scale=1">

      <script src="https://unpkg.com/@webcomponents/webcomponentsjs@2.1.3/custom-elements-es5-adapter.js"></script>
      <script src="https://unpkg.com/zone.js"></script>
      <script type="text/javascript" src="/profile.js"></script>


      <link rel="icon" type="image/x-icon" href="favicon.ico">
    </head>
    <body>
      <app-profile></app-profile>
      <app-root></app-root> 
    </body>
    </html>

Avinash Dalvi
  • 8,551
  • 7
  • 27
  • 53
divya dave
  • 471
  • 1
  • 9
  • 28
  • Can you paste the code for profile.js – Abhijit Chakra Dec 10 '19 at 18:39
  • where did you put the `profile.js` in the folder structure of the second Angular project? And how are you running the application - using `ng serve`? – ulmas Dec 10 '19 at 19:45
  • And I moved profile.js into the dist folder of the second angular project and Yes, I am running application using ng serve still it is not working getting error as the server responded with a status of 404 (Not Found) – divya dave Dec 11 '19 at 06:07
  • did you ever find a solution for this? – Trent Jul 21 '22 at 16:36

1 Answers1

0

My guess is that you put the profile.js file together with the source files of the Angular project. Try moving it into the dist folder (the folder where compiled files are placed, and from which the compiled application is served when you run ng serve)

ulmas
  • 2,203
  • 16
  • 22
  • I tried adding profile.js into the dist folder still getting error as the server responded with a status of 404 (Not Found) – divya dave Dec 11 '19 at 06:04