Skip to content
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

Error when:: import {$http, $log} from 'ngimport' #13

Open
umar-siddiqui opened this issue Jul 18, 2018 · 3 comments
Open

Error when:: import {$http, $log} from 'ngimport' #13

umar-siddiqui opened this issue Jul 18, 2018 · 3 comments

Comments

@umar-siddiqui
Copy link

When i am importing ngimport like given getting and error

import {IPromise} from 'angular'
import {$http, $log} from 'ngimport'

Error on browser console

Uncaught TypeError: angular.module is not a function
    at Object.124 (index.js:11)
    at __webpack_require__ (bootstrap be5679f8ce158294b682:19)
    at Object.123 (application.js:16)
    at __webpack_require__ (bootstrap be5679f8ce158294b682:19)
    at Object.245 (analytics.js:1)
    at __webpack_require__ (bootstrap be5679f8ce158294b682:19)
    at bootstrap be5679f8ce158294b682:62
    at bootstrap be5679f8ce158294b682:62

And if we use a debugger on that line which has the error angular is an empty object

@bcherny
Copy link
Owner

bcherny commented Jul 19, 2018

Hey @umar-siddiqui! How can I reproduce this? Can you link a repro case on StackBlitz

@umar-siddiqui
Copy link
Author

umar-siddiqui commented Jul 21, 2018

Hi @bcherny
Below is the link to the repo as requested
using [email protected]

https://stackblitz.com/edit/react-knhadu

even in the case of newer angular version (1.7) getting below error

Error in index.js (16:10)
Cannot read property 'get' of undefined

but would want it to work for 1.3.13 specifically.

@bcherny
Copy link
Owner

bcherny commented Jul 21, 2018

Thanks @umar-siddiqui! A few things:

  1. Don't forget to bootstrap your Angular app.
  2. We only support Angular 1.5+. If you'd like to add support for older Angular versions, feel free to submit a Pull Request.
  3. Are you using Webpack? Something seems to have changed, where individual exports don't work anymore. For now, using a default export fixes this.

See fixed demo here: https://stackblitz.com/edit/react-zdvaty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants