(fn, self, locals, serviceName)
| 4447 | } |
| 4448 | |
| 4449 | function invoke(fn, self, locals, serviceName) { |
| 4450 | if (typeof locals === 'string') { |
| 4451 | serviceName = locals; |
| 4452 | locals = null; |
| 4453 | } |
| 4454 | |
| 4455 | var args = [], |
| 4456 | $inject = createInjector.$$annotate(fn, strictDi, serviceName), |
| 4457 | length, i, |
| 4458 | key; |
| 4459 | |
| 4460 | for (i = 0, length = $inject.length; i < length; i++) { |
| 4461 | key = $inject[i]; |
| 4462 | if (typeof key !== 'string') { |
| 4463 | throw $injectorMinErr('itkn', |
| 4464 | 'Incorrect injection token! Expected service name as string, got {0}', key); |
| 4465 | } |
| 4466 | args.push( |
| 4467 | locals && locals.hasOwnProperty(key) |
| 4468 | ? locals[key] |
| 4469 | : getService(key, serviceName) |
| 4470 | ); |
| 4471 | } |
| 4472 | if (isArray(fn)) { |
| 4473 | fn = fn[length]; |
| 4474 | } |
| 4475 | |
| 4476 | // http://jsperf.com/angularjs-invoke-apply-vs-switch |
| 4477 | // #5388 |
| 4478 | return fn.apply(self, args); |
| 4479 | } |
| 4480 | |
| 4481 | function instantiate(Type, locals, serviceName) { |
| 4482 | // Check if Type is annotated and use just the given function at n-1 as parameter |
no test coverage detected