JavaScript Injecting jQuery namespace into AngularJS

I'm having a bit of a trouble here.

I'm using RequireJS to load my modules and dependencies. I am trying to avoid polluting the global namespace, so I am using the following configuration as a starting point, to avoid defining $ or jQuery in the global window object:

require.config({
    map: {
       '*': { 'jquery': 'jquery-no-conflict' },
       'jquery-no-conflict': { 'jquery': 'jquery' }
    },
    shim: {
       'jquery': { exports: 'jQuery' },
       'angular': { exports: 'angular', deps: ['jquery'] }
       // ...
    }
});

The module jquery-no-conflict would look like this:

define('jquery-no-conflict', ['jquery'], function (jQuery) {
    return jQuery.noConflict(true);
});

This apparently solves the issue, but there is a problem.

I was not aware that there is some AngularJS behavior that is different wether jQuery is loaded or not, and apparently, this is done by inspecting the global namespace.

For instance, AngularJS $window would be a wrapper of the native element window if no jQuery is found or loaded, but it would be a wrapper of jQuery's $(window) if jQuery is defined.

For some functionality on my website, I need the latter, but with this configuration, I am getting the former (because AngularJS does not seem to find jQuery);

Is there some way to inject my jQuery module/variable to AngularJS and have it not inspect the global namespace?

As you can see my jquery module is being exported, so RequireJS will give me a scoped variable when requesting it.

If this isn't possible, what would you do in my situation? What can be done to work around this?

Answer:1

If conventional jQuery globals cause problems, a custom window property can be provided for jQuery with ng-jq attrubute.

As of today Angular still relies on globals, jQuery isn't an exception.

Answer:2

I'm currently trying to display number series (for 2, 3, 4, 5, 6 and 7) in JavaScript. I was looking for the smallest number (x), which results in modulo = 1, if divided by 2, 3, 4, 5 and 6. If the ...

I'm currently trying to display number series (for 2, 3, 4, 5, 6 and 7) in JavaScript. I was looking for the smallest number (x), which results in modulo = 1, if divided by 2, 3, 4, 5 and 6. If the ...

  1. display prime number series in python

I am working on a search function for a parent child structure with locations (city,suburb,street). I want to search for a street name and get the results but keeping the structure. The array ...

I am working on a search function for a parent child structure with locations (city,suburb,street). I want to search for a street name and get the results but keeping the structure. The array ...

  1. filter search multiple values excel
  2. filter search multiple values
  3. filter search multiple excel
  4. filter search multiple pivot
  5. search filter multiple
  6. search filter multiple php
  7. excel filter search multiple words
  8. django-filter search multiple fields
  9. angularjs filter search multiple fields
  10. angular filter search multiple fields
  11. excel filter search multiple criteria
  12. excel filter search multiple entries
  13. excel filter search multiple items
  14. excel filter search multiple columns
  15. angularjs search filter multiple parameters
  16. ldap search filter multiple ou
  17. angular search filter multiple parameters
  18. ldap search filter multiple groups
  19. ldap search filter multiple attributes
  20. ldap search filter multiple cn

It's silly, I know - every time I change environment I comment out and back my app's config factory. There must be a better way, is there? I though of checking the URL but this seems like a bad ...

It's silly, I know - every time I change environment I comment out and back my app's config factory. There must be a better way, is there? I though of checking the URL but this seems like a bad ...

When would I do <CustomComponent function = {this.FunctionName}/> instead of <CustomComponent function = {this.FunctionName.bind(this)}? React's documentation mentions that bind() solves ...

When would I do <CustomComponent function = {this.FunctionName}/> instead of <CustomComponent function = {this.FunctionName.bind(this)}? React's documentation mentions that bind() solves ...

  1. please simply explain