Angular核心概念
依赖性注入
constructor(private oc:overlayContainer){
const injector =ReflectiveInjector.redolveAndCreate({
{provide:Person,useClass:Person},
{provide:Address,useFactory:()=>{
if(environment.production){
return new Address('北京','朝阳');
}else{
return new Address('西藏','拉萨')
}
}
},
{provide:Id,useFactory:()=>{
return Id.getInstance('idcard');
}
}
}ChangeDetection
Last updated