angular-clipboard icon indicating copy to clipboard operation
angular-clipboard copied to clipboard

Check for angular being available as global variable before using require

Open johannesjo opened this issue 7 years ago • 4 comments

When I've a context where there is require available, but loading angular directly via a file (which might very well be the case for an electron app), your method of requiring angular throws errors. If you add a simple check if angular is defined as global variable first, everything should be fine.

johannesjo avatar Feb 09 '17 20:02 johannesjo

I am using standard UMD which should be compatible with both CJS (node/electron) as well as requirejs and normal browser loading.

If angular is not available before this module is loaded, it will not work. It needs to register itself in the angular runtime to be available.

I suspect you need to refactor your code a bit to ensure that angular loads before any plugins/extensions.

omichelsen avatar Feb 21 '17 19:02 omichelsen

Angular is loaded before, is available as global var and works fine, but it is not included as node module, but via simple (Bower based) file include. When a global require function is available too as it will be for electron apps, you're module throws errors.

johannesjo avatar Feb 21 '17 23:02 johannesjo

it's working on a specified version of angular? i'm using the last version of angular and i get this error : Error: $injector:modulerr Module Error. Error: [$injector:modulerr] http://errors.angularjs.org/1.5.8/$injector/modulerr?p0=a...) at http://prestodev.itsign.ro/bundles/mountfrontend/bower_components/angular/angular.min.js?version=v14:6:412

please help :(

andreifrnc avatar May 11 '17 13:05 andreifrnc

I have the same problem, do you have any news?

andreaazzara avatar Oct 29 '17 14:10 andreaazzara