mirror of https://github.com/abpframework/abp.git
3 changed files with 32 additions and 0 deletions
@ -1,2 +1,3 @@ |
|||
export * from './localization.pipe'; |
|||
export * from './sort.pipe'; |
|||
export * from './to-injector.pipe'; |
|||
|
|||
@ -0,0 +1,28 @@ |
|||
import { InjectionToken, Injector, Pipe, PipeTransform } from '@angular/core'; |
|||
|
|||
export const INJECTOR_PIPE_DATA_TOKEN = new InjectionToken<PipeTransform>( |
|||
'INJECTOR_PIPE_DATA_TOKEN', |
|||
); |
|||
|
|||
@Pipe({ |
|||
name: 'toInjector', |
|||
}) |
|||
export class ToInjectorPipe implements PipeTransform { |
|||
constructor(private injector: Injector) {} |
|||
transform( |
|||
value: any, |
|||
token: InjectionToken<any> = INJECTOR_PIPE_DATA_TOKEN, |
|||
name = 'ToInjectorPipe', |
|||
): Injector { |
|||
return Injector.create({ |
|||
providers: [ |
|||
{ |
|||
provide: token, |
|||
useValue: value, |
|||
}, |
|||
], |
|||
parent: this.injector, |
|||
name, |
|||
}); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue