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): it cls is a value provider class with a prototype method value()


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


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