-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinject.js
31 lines (25 loc) · 867 Bytes
/
inject.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import AngularController from './AngularController'
import {todo} from './_common'
function inject (...services) {
return function doInject (classDescriptor) {
return {
...classDescriptor,
finisher (Controller) {
const inherited = Controller.$inject
if (inherited) {
services = Array.from(new Set([...inherited, ...services]))
}
Controller.$inject = services
function afterInject (...args) {
services.forEach((name, index) => {
this[name] = args[index]
})
}
afterInject.selfish = true
todo(Controller, afterInject, 'before')
}
}
}
}
AngularController.inject = inject
export default inject