(fn, self, locals, serviceName)
| 4188 | } |
| 4189 | |
| 4190 | function invoke(fn, self, locals, serviceName) { |
| 4191 | if (typeof locals === 'string') { |
| 4192 | serviceName = locals; |
| 4193 | locals = null; |
| 4194 | } |
| 4195 | |
| 4196 | var args = [], |
| 4197 | $inject = createInjector.$$annotate(fn, strictDi, serviceName), |
| 4198 | length, i, |
| 4199 | key; |
| 4200 | |
| 4201 | for (i = 0, length = $inject.length; i < length; i++) { |
| 4202 | key = $inject[i]; |
| 4203 | if (typeof key !== 'string') { |
| 4204 | throw $injectorMinErr('itkn', |
| 4205 | 'Incorrect injection token! Expected service name as string, got {0}', key); |
| 4206 | } |
| 4207 | args.push( |
| 4208 | locals && locals.hasOwnProperty(key) |
| 4209 | ? locals[key] |
| 4210 | : getService(key, serviceName) |
| 4211 | ); |
| 4212 | } |
| 4213 | if (isArray(fn)) { |
| 4214 | fn = fn[length]; |
| 4215 | } |
| 4216 | |
| 4217 | // http://jsperf.com/angularjs-invoke-apply-vs-switch |
| 4218 | // #5388 |
| 4219 | return fn.apply(self, args); |
| 4220 | } |
| 4221 | |
| 4222 | function instantiate(Type, locals, serviceName) { |
| 4223 | // Check if Type is annotated and use just the given function at n-1 as parameter |
no test coverage detected