SWEBDEV Telegram 3414
Декоратор @SkipSelf() для исключения текущего провайдера из цепочки инъекций

@SkipSelf() в Angular заставляет DI пропустить текущий провайдер и искать зависимость в родительском инжекторе. Это полезно, если нужно использовать родительский провайдер вместо локального.

Пример:
@Injectable({ providedIn: 'root' })
export class ConfigService {
constructor(public config: string) {}
}

@Component({
selector: 'app-parent',
providers: [{ provide: ConfigService, useValue: new ConfigService('Parent Config') }],
template: `<app-child></app-child>`,
})
export class ParentComponent {}

@Component({
selector: 'app-child',
providers: [{ provide: ConfigService, useValue: new ConfigService('Child Config') }],
template: `{{ configService.config }}`,
})
export class ChildComponent {
constructor(@SkipSelf() public configService: ConfigService) {}
}

@SkipSelf() исключает локальный ConfigService в ChildComponent, используя родительский провайдер.

👉 @sWebDev
👍61



tgoop.com/sWebDev/3414
Create:
Last Update:

Декоратор @SkipSelf() для исключения текущего провайдера из цепочки инъекций

@SkipSelf() в Angular заставляет DI пропустить текущий провайдер и искать зависимость в родительском инжекторе. Это полезно, если нужно использовать родительский провайдер вместо локального.

Пример:

@Injectable({ providedIn: 'root' })
export class ConfigService {
constructor(public config: string) {}
}

@Component({
selector: 'app-parent',
providers: [{ provide: ConfigService, useValue: new ConfigService('Parent Config') }],
template: `<app-child></app-child>`,
})
export class ParentComponent {}

@Component({
selector: 'app-child',
providers: [{ provide: ConfigService, useValue: new ConfigService('Child Config') }],
template: `{{ configService.config }}`,
})
export class ChildComponent {
constructor(@SkipSelf() public configService: ConfigService) {}
}

@SkipSelf() исключает локальный ConfigService в ChildComponent, используя родительский провайдер.

👉 @sWebDev

BY Frontender Libs - обзор библиотек JS / CSS




Share with your friend now:
tgoop.com/sWebDev/3414

View MORE
Open in Telegram


Telegram News

Date: |

How to Create a Private or Public Channel on Telegram? How to Create a Private or Public Channel on Telegram? With Bitcoin down 30% in the past week, some crypto traders have taken to Telegram to “voice” their feelings. As of Thursday, the SUCK Channel had 34,146 subscribers, with only one message dated August 28, 2020. It was an announcement stating that police had removed all posts on the channel because its content “contravenes the laws of Hong Kong.” Just as the Bitcoin turmoil continues, crypto traders have taken to Telegram to voice their feelings. Crypto investors can reduce their anxiety about losses by joining the “Bear Market Screaming Therapy Group” on Telegram.
from us


Telegram Frontender Libs - обзор библиотек JS / CSS
FROM American