I have a doubt about how to pass the value in the constructor using a singleton class in typescript.
mycode .ts
import {singleton} from "tsyringe";
@singleton()
class Foo {
constructor(data:string)
{
this.data = data
}
}
// some other file
import "reflect-metadata";
import {container} from "tsyringe";
import {Foo} from "./foo";
const instance = container.resolve(Foo);
how to pass a value in the constructor using constainer .resolve function .any one gives the example code how to pass the value.
You can do the following to inject a value into the constructor: