aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Morrin2012-11-06 17:35:47 -0500
committerMisko Hevery2013-02-14 14:43:55 -0800
commit12ba6cec4fb79521101744e02a7e09f9fbb591c4 (patch)
tree618987b1edd5ec5a871a000e45b6b69d35e889f6 /src
parentb7e1fb0515798e1b4f3f2426f6b050951bee2617 (diff)
downloadangular.js-12ba6cec4fb79521101744e02a7e09f9fbb591c4.tar.bz2
feat(noConflict): restore previous angular namespace reference
Diffstat (limited to 'src')
-rw-r--r--src/Angular.js20
-rw-r--r--src/AngularPublic.js3
2 files changed, 22 insertions, 1 deletions
diff --git a/src/Angular.js b/src/Angular.js
index 5195489e..6ea5d1ad 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -57,6 +57,8 @@ var /** holds major version number for IE or NaN for real browsers */
push = [].push,
toString = Object.prototype.toString,
+
+ _angular = window.angular,
/** @name angular */
angular = window.angular || (window.angular = {}),
angularModule,
@@ -65,6 +67,24 @@ var /** holds major version number for IE or NaN for real browsers */
/**
* @ngdoc function
+ * @name angular.noConflict
+ * @function
+ *
+ * @description
+ * Restores the previous global value of angular and returns the current instance. Other libraries may already use the
+ * angular namespace. Or a previous version of angular is already loaded on the page. In these cases you may want to
+ * restore the previous namespace and keep a reference to angular.
+ *
+ * @return {Object} The current angular namespace
+ */
+function noConflict() {
+ var a = window.angular;
+ window.angular = _angular;
+ return a;
+}
+
+/**
+ * @ngdoc function
* @name angular.forEach
* @function
*
diff --git a/src/AngularPublic.js b/src/AngularPublic.js
index 61c77af3..9928a125 100644
--- a/src/AngularPublic.js
+++ b/src/AngularPublic.js
@@ -48,7 +48,8 @@ function publishExternalAPI(angular){
'isDate': isDate,
'lowercase': lowercase,
'uppercase': uppercase,
- 'callbacks': {counter: 0}
+ 'callbacks': {counter: 0},
+ 'noConflict': noConflict
});
angularModule = setupModuleLoader(window);