aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Angular.js2
-rw-r--r--src/Compiler.js2
-rw-r--r--src/Scope.js20
-rw-r--r--src/validators.js2
-rw-r--r--src/widgets.js2
5 files changed, 22 insertions, 6 deletions
diff --git a/src/Angular.js b/src/Angular.js
index 991598e1..96d478f3 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -947,7 +947,7 @@ function angularInit(config){
if (config.autobind) {
// TODO default to the source of angular.js
var scope = compile(window.document, _null, {'$config':config}),
- $browser = scope.$inject('$browser');
+ $browser = scope.$service('$browser');
if (config.css)
$browser.addCss(config.base_url + config.css);
diff --git a/src/Compiler.js b/src/Compiler.js
index a98bd502..5a841a25 100644
--- a/src/Compiler.js
+++ b/src/Compiler.js
@@ -35,7 +35,7 @@ Template.prototype = {
foreach(this.inits, function(fn) {
queue.push(function() {
childScope.$tryEval(function(){
- return childScope.$inject(fn, childScope, element);
+ return childScope.$service(fn, childScope, element);
}, element);
});
});
diff --git a/src/Scope.js b/src/Scope.js
index 27df770d..393e015b 100644
--- a/src/Scope.js
+++ b/src/Scope.js
@@ -578,7 +578,7 @@ function createScope(parent, providers, instanceCache) {
foreach(Class.prototype, function(fn, name){
instance[name] = bind(instance, fn);
});
- instance.$inject.apply(instance, concat([Class, instance], arguments, 1));
+ instance.$service.apply(instance, concat([Class, instance], arguments, 1));
//TODO: backwards compatibility hack, remove when we don't depend on init methods
if (isFunction(Class.prototype.init)) {
@@ -615,7 +615,23 @@ function createScope(parent, providers, instanceCache) {
if (!parent.$root) {
instance.$root = instance;
instance.$parent = instance;
- (instance.$inject = createInjector(instance, providers, instanceCache))();
+
+ /**
+ * @workInProgress
+ * @ngdoc function
+ * @name angular.scope.$service
+ * @function
+ *
+ * @description
+ * Provides access to angular's dependency injector and
+ * {@link angular.service registered services}. In general the use of this api is discouraged,
+ * except for tests and components that currently don't support dependency injection (widgets,
+ * filters, etc).
+ *
+ * @param {string} serviceId String ID of the service to return.
+ * @returns {*} Value, object or function returned by the service factory function if any.
+ */
+ (instance.$service = createInjector(instance, providers, instanceCache))();
}
return instance;
diff --git a/src/validators.js b/src/validators.js
index b55db341..3de98d61 100644
--- a/src/validators.js
+++ b/src/validators.js
@@ -383,7 +383,7 @@ extend(angularValidator, {
cache.current = input;
var inputState = cache.inputs[input],
- $invalidWidgets = scope.$inject('$invalidWidgets');
+ $invalidWidgets = scope.$service('$invalidWidgets');
if (!inputState) {
cache.inputs[input] = inputState = { inFlight: true };
diff --git a/src/widgets.js b/src/widgets.js
index a09ee29d..05979281 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -271,7 +271,7 @@ function valueAccessor(scope, element) {
formatterName = element.attr('ng:format') || NOOP,
formatter = angularFormatter(formatterName),
format, parse, lastError, required,
- invalidWidgets = scope.$inject('$invalidWidgets') || {markValid:noop, markInvalid:noop};
+ invalidWidgets = scope.$service('$invalidWidgets') || {markValid:noop, markInvalid:noop};
if (!validator) throw "Validator named '" + validatorName + "' not found.";
if (!formatter) throw "Formatter named '" + formatterName + "' not found.";
format = formatter.format;