projects/i-components/src/lib/pipes/xamGridTemplateToinjector.pipe.ts
Pipe for creating an injector given an object
Given that this is a pure pipe this class is useful to create custom injectors when using ngComponentOutlet in template controls
Name | xamTemplateToInjector |
Pure | true |
transform |
transform(value: any, dContext: any)
|
Returns :
any
|
import { Injector, Pipe, PipeTransform } from '@angular/core';
import {
TEMPLATE_COMPONENT_CONTEXT,
TEMPLATE_DECLARING_CONTEXT,
} from '@mobilize/wms-framework';
/**
* Pipe for creating an injector given an object
*
* Given that this is a *pure* pipe this class is useful to
* create custom injectors when using *ngComponentOutlet* in template controls
*
* @export
* @class XamTemplateToInjectorPurePipe
* @implements {PipeTransform}
*/
@Pipe({
name: 'xamTemplateToInjector',
pure: true,
})
export class XamTemplateToInjectorPurePipe implements PipeTransform {
constructor(private injector: Injector) {}
transform(value: any, dContext: any = null): any {
return Injector.create({
providers: [
{
provide: TEMPLATE_COMPONENT_CONTEXT,
useValue: value,
deps: [],
},
{
provide: TEMPLATE_DECLARING_CONTEXT,
useValue: dContext,
deps: [],
},
],
parent: this.injector,
});
}
}