如何将参数(数字)传递给工厂函数:
const id = 1;
{ provide: MyClass, useFactory: myFactory, deps: [ActivatedRoute] }
//how to pass the id here?
function myFactory(id, activatedRoute) {
...
}
你尝试过这样的事情吗
const id = 1;
{ provide: MyClass, useFactory: (route:ActivatedRoute)=>myFactory(id,route), deps: [ActivatedRoute] }
function myFactory(id, activatedRoute) {
...
}