1

I need to install angular 1.3.18 and 1.4.5 version of angular using bower in same project.Since some part of my code using angular 1.3.18 and some of its dependecy are also using 1.3.18, same case for other version as well. If I am using only one version some part of code will get broken.

If I use below method

"dependencies": {
"angular": "1.4.5",
"angular": "1.3.18"
}

it is working fine ,After I minify and uglify the code for production only one version of angular is available and some part of code is broken.

Please suggest me a solution for this..

Akhil Xavier
  • 1,095
  • 10
  • 18
  • Possible duplicate of [Bower: Install 2 versions of jQuery](http://stackoverflow.com/questions/16442012/bower-install-2-versions-of-jquery) – Damjan Pavlica Mar 07 '17 at 08:48

2 Answers2

1

Just modify your bower.json as follows:

{
  "dependencies": {
    "angular": "~1.4.5",
    "another_angular": "angular#1.3.18"
  }
}

The another_angular package is now available in another_angular folder in your bower_components.

Note: The key another_angular can be changed at will (in the limits of an acceptable property name in JSON!), but beware that the destination folder will change accordingly.

  • 1
    I tried this.Two folders are created and two different version of angular is available.but when I minify the all the vendor code(bower scripts) only one version of angular is available.any solution? – Akhil Xavier Sep 01 '15 at 11:05
  • I would recommend to rely on modules in your code instead of globals. Then in your files, specify the version you want to use. But I don't know enough of your environment for a better answer. – xavier.cambar Sep 01 '15 at 17:33
1

While angular is not designed to have multiple versions running in the same window (they both assign to window.angular), it is possible using the hack described here:

Multiple versions of AngularJS in one page

The minification issue you are experiencing is most likely due to both versions of angular being assigned to the same global variable, window.angular, and your minifier is over-riding one assignment of that variable (for 1.3.18) with the other (for 1.4.5).

Community
  • 1
  • 1
jpstevens
  • 21
  • 1