Angular 依赖注入
Angular 依赖注入 和.NetCore 的对比:
| Angular | .Netcore | Example |
| Injector | ServiceProvider |
constructor(injector: Injector) { this.localization = injector.get(LocalizationService); this.permission = injector.get(PermissionCheckerService); this.feature = injector.get(FeatureCheckerService); this.notify = injector.get(NotifyService); this.setting = injector.get(SettingService); this.message = injector.get(MessageService); this.multiTenancy = injector.get(AbpMultiTenancyService); this.appSession = injector.get(AppSessionService); this.elementRef = injector.get(ElementRef); this.modalHelper = injector.get(ModalHelper); } |
| @Injectable |
自定义标签 类上修饰 |
@Injectable() export class AppSessionService { private _user: UserLoginInfoDto; private _tenant: TenantLoginInfoDto; private _application: ApplicationInfoDto; 。。。 } |
| @Inject |
自定义标签, 参数上修饰 |
constructor(@Inject(HttpClient) http: HttpClient, @Optional() @Inject(API_BASE_URL) baseUrl?: string) { this.http = http; this.baseUrl = baseUrl ? baseUrl : ""; } |
| Arabic | Hebrew | Polish |
| Bulgarian | Hindi | Portuguese |
| Catalan | Hmong Daw | Romanian |
| Chinese Simplified | Hungarian | Russian |
| Chinese Traditional | Indonesian | Slovak |
| Czech | Italian | Slovenian |
| Danish | Japanese | Spanish |
| Dutch | Klingon | Swedish |
| English | Korean | Thai |
| Estonian | Latvian | Turkish |
| Finnish | Lithuanian | Ukrainian |
| French | Malay | Urdu |
| German | Maltese | Vietnamese |
| Greek | Norwegian | Welsh |
| Haitian Creole | Persian |