Notice: file_put_contents(): Write of 16802 bytes failed with errno=28 No space left on device in /var/www/tgoop/post.php on line 50
Frontender Libs - обзор библиотек JS / CSS@sWebDev P.3659
SWEBDEV Telegram 3659
Ручной запуск обновления

Метод ɵmarkDirty() в Angular вручную помечает компонент как «грязный», инициируя обновление при следующем цикле детекции изменений. Это используется вне зоны Angular (например, в стороннем коде), и работает только с ChangeDetectionStrategy.OnPush.

import {
Component,
ChangeDetectionStrategy,
ɵmarkDirty
} from '@angular/core';

declare const externalClick: (cb: () => void) => void;

@Component({
selector: 'app-alert',
template: `<p *ngIf="visible">Внешнее событие!</p>`,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class AlertComponent {
visible = false;

ngOnInit() {
externalClick(() => {
this.visible = true;
ɵmarkDirty(this);
});
}
}


В этом примере внешний обработчик (externalClick) активирует компонент, не запуская Angular change detection. Мы вручную вызываем ɵmarkDirty(this), чтобы Angular отрендерил компонент на следующем проходе.

👉 @sWebDev
👍4



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

Ручной запуск обновления

Метод ɵmarkDirty() в Angular вручную помечает компонент как «грязный», инициируя обновление при следующем цикле детекции изменений. Это используется вне зоны Angular (например, в стороннем коде), и работает только с ChangeDetectionStrategy.OnPush.

import {
Component,
ChangeDetectionStrategy,
ɵmarkDirty
} from '@angular/core';

declare const externalClick: (cb: () => void) => void;

@Component({
selector: 'app-alert',
template: `<p *ngIf="visible">Внешнее событие!</p>`,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class AlertComponent {
visible = false;

ngOnInit() {
externalClick(() => {
this.visible = true;
ɵmarkDirty(this);
});
}
}


В этом примере внешний обработчик (externalClick) активирует компонент, не запуская Angular change detection. Мы вручную вызываем ɵmarkDirty(this), чтобы Angular отрендерил компонент на следующем проходе.

👉 @sWebDev

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




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

View MORE
Open in Telegram


Telegram News

Date: |

The group’s featured image is of a Pepe frog yelling, often referred to as the “REEEEEEE” meme. Pepe the Frog was created back in 2005 by Matt Furie and has since become an internet symbol for meme culture and “degen” culture. To view your bio, click the Menu icon and select “View channel info.” With the sharp downturn in the crypto market, yelling has become a coping mechanism for many crypto traders. This screaming therapy became popular after the surge of Goblintown Ethereum NFTs at the end of May or early June. Here, holders made incoherent groaning sounds in late-night Twitter spaces. They also role-played as urine-loving Goblin creatures. Among the requests, the Brazilian electoral Court wanted to know if they could obtain data on the origins of malicious content posted on the platform. According to the TSE, this would enable the authorities to track false content and identify the user responsible for publishing it in the first place. Although some crypto traders have moved toward screaming as a coping mechanism, several mental health experts call this therapy a pseudoscience. The crypto community finds its way to engage in one or the other way and share its feelings with other fellow members.
from us


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