(fn, self, locals, serviceName)
| 4138 | } |
| 4139 | |
| 4140 | function invoke(fn, self, locals, serviceName) { |
| 4141 | if (typeof locals === 'string') { |
| 4142 | serviceName = locals; |
| 4143 | locals = null; |
| 4144 | } |
| 4145 | |
| 4146 | var args = [], |
| 4147 | $inject = annotate(fn, strictDi, serviceName), |
| 4148 | length, i, |
| 4149 | key; |
| 4150 | |
| 4151 | for (i = 0, length = $inject.length; i < length; i++) { |
| 4152 | key = $inject[i]; |
| 4153 | if (typeof key !== 'string') { |
| 4154 | throw $injectorMinErr('itkn', |
| 4155 | 'Incorrect injection token! Expected service name as string, got {0}', key); |
| 4156 | } |
| 4157 | args.push( |
| 4158 | locals && locals.hasOwnProperty(key) |
| 4159 | ? locals[key] |
| 4160 | : getService(key, serviceName) |
| 4161 | ); |
| 4162 | } |
| 4163 | if (isArray(fn)) { |
| 4164 | fn = fn[length]; |
| 4165 | } |
| 4166 | |
| 4167 | // http://jsperf.com/angularjs-invoke-apply-vs-switch |
| 4168 | // #5388 |
| 4169 | return fn.apply(self, args); |
| 4170 | } |
| 4171 | |
| 4172 | function instantiate(Type, locals, serviceName) { |
| 4173 | // Check if Type is annotated and use just the given function at n-1 as parameter |
no test coverage detected