Skip to content

Getting error while importing js file from assets folder and using in angular component Angular 8.0.x #15115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
narendrasinghrathore opened this issue Jul 18, 2019 · 4 comments

Comments

@narendrasinghrathore
Copy link

narendrasinghrathore commented Jul 18, 2019

I have a external .js file which i downloaded and placed into my assets folder.
After following steps from here, still no success.

Steps performed to add js file in angular project;

  1. Adding relative path of js file to script [] in angular.json

  2. Creating typyings.d.ts under src folder
    declare var myJs: any;

  3. Import in component
    import * as myJs from 'myJs'

Getting error; undefined

Stakcblitz url: https://stackblitz.com/edit/angular-lollipop-chart
Github repo: https://github.com/narendrasinghrathore/angular-lollipop-chart

Regards

"dependencies": {
  "@angular/animations": "^8.1.2",
  "@angular/common": "^8.1.2",
  "@angular/compiler": "^8.1.2",
  "@angular/core": "^8.1.2",
  "@angular/forms": "^8.1.2",
  "@angular/platform-browser": "^8.1.2",
  "@angular/platform-browser-dynamic": "^8.1.2",
  "@angular/router": "^8.1.2",
  "@types/jasmine": "^3.3.13",
  "@types/jasminewd2": "^2.0.6",
  "@types/node": "^12.6.8",
  "d3": "^5.9.7",
  "rxjs": "^6.5.2",
  "tslib": "^1.10.0",
  "zone.js": "^0.9.1"
},
@alan-agius4
Copy link
Collaborator

Might be related to #15102

@alan-agius4
Copy link
Collaborator

Actually it should have been already solved via #14985.

If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

@narendrasinghrathore
Copy link
Author

narendrasinghrathore commented Jul 18, 2019

@alan-agius4 did you mean to upgrade version 8.1 ?

Update++
I am upgrading to 8.1.0.

Can you please share any documentation that help me to include my .js file from assets or any folder from within src folder in angular app build and use in our angular component ?

Regards

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants