MCPcopy Index your code
hub / github.com/angular-ui/ui-router / invoke

Function invoke

test/angular/1.4/angular.js:4541–4571  ·  view source on GitHub ↗
(fn, self, locals, serviceName)

Source from the content-addressed store, hash-verified

4539 }
4540
4541 function invoke(fn, self, locals, serviceName) {
4542 if (typeof locals === 'string') {
4543 serviceName = locals;
4544 locals = null;
4545 }
4546
4547 var args = [],
4548 $inject = createInjector.$$annotate(fn, strictDi, serviceName),
4549 length, i,
4550 key;
4551
4552 for (i = 0, length = $inject.length; i < length; i++) {
4553 key = $inject[i];
4554 if (typeof key !== 'string') {
4555 throw $injectorMinErr('itkn',
4556 'Incorrect injection token! Expected service name as string, got {0}', key);
4557 }
4558 args.push(
4559 locals && locals.hasOwnProperty(key)
4560 ? locals[key]
4561 : getService(key, serviceName)
4562 );
4563 }
4564 if (isArray(fn)) {
4565 fn = fn[length];
4566 }
4567
4568 // http://jsperf.com/angularjs-invoke-apply-vs-switch
4569 // #5388
4570 return fn.apply(self, args);
4571 }
4572
4573 function instantiate(Type, locals, serviceName) {
4574 // Check if Type is annotated and use just the given function at n-1 as parameter

Callers 1

instantiateFunction · 0.70

Calls 2

isArrayFunction · 0.85
getServiceFunction · 0.70

Tested by

no test coverage detected