ngimport icon indicating copy to clipboard operation
ngimport copied to clipboard

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

Open umar-siddiqui opened this issue 7 years ago • 3 comments

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

umar-siddiqui avatar Jul 18 '18 08:07 umar-siddiqui

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

bcherny avatar Jul 19 '18 03:07 bcherny

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.

umar-siddiqui avatar Jul 21 '18 10:07 umar-siddiqui

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

bcherny avatar Jul 21 '18 20:07 bcherny