Page Contents

Home > @loopback/context > createBindingFromClass

createBindingFromClass() function

Create a binding from a class with decorated metadata. The class is attached to the binding as follows: - binding.toClass(cls): if cls is a plain class such as MyController - binding.toProvider(cls): if cls is a value provider class with a prototype method value() - binding.toDynamicValue(cls): if cls is a dynamic value provider class with a static method value()


export declare function createBindingFromClass<T>(cls: Constructor<T | Provider<T>> | DynamicValueProviderClass<T>, options?: BindingFromClassOptions): Binding<T>;


Parameter Type Description
cls Constructor<T | Provider<T>> | DynamicValueProviderClass<T> A class. It can be either a plain class, a value provider class, or a dynamic value provider class
options BindingFromClassOptions (Optional) Options to customize the binding key