一:在項目核心文件core.module.ts中設置全局靜態常量
解釋:相當於自動注入到inject中。
providers:[
{
provide:'BASE_CONFIG',
useValue:'http://localhost:4200/'
}
]
二:在需要獲取此常量的模塊中調用
constructor(@Inject('BASE_CONFIG') config){
console.log(config,'-config');
}