SWEBDEV Telegram 3444
Ручное обновление дерева компонентов

В Angular метод ApplicationRef.tick() используется для запуска цикла обнаружения изменений вручную. Это полезно, когда изменения происходят вне зоны Angular, например, в callback-функциях или таймерах.

Пример:
typescript  
import { ApplicationRef, Component } from '@angular/core';

@Component({
selector: 'app-manual-tick',
template: `<p>{{ message }}</p>`,
})
export class ManualTickComponent {
message = 'Ожидание...';

constructor(private appRef: ApplicationRef) {
setTimeout(() => {
this.message = 'Изменение произошло';
this.appRef.tick(); // Обновляем вручную
}, 3000);
}
}

Без вызова tick() изменения в message не были бы отражены в шаблоне, так как они происходят вне зоны Angular.

👉 @sWebDev
👍4



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

Ручное обновление дерева компонентов

В Angular метод ApplicationRef.tick() используется для запуска цикла обнаружения изменений вручную. Это полезно, когда изменения происходят вне зоны Angular, например, в callback-функциях или таймерах.

Пример:

typescript  
import { ApplicationRef, Component } from '@angular/core';

@Component({
selector: 'app-manual-tick',
template: `<p>{{ message }}</p>`,
})
export class ManualTickComponent {
message = 'Ожидание...';

constructor(private appRef: ApplicationRef) {
setTimeout(() => {
this.message = 'Изменение произошло';
this.appRef.tick(); // Обновляем вручную
}, 3000);
}
}

Без вызова tick() изменения в message не были бы отражены в шаблоне, так как они происходят вне зоны Angular.

👉 @sWebDev

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




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

View MORE
Open in Telegram


Telegram News

Date: |

On June 7, Perekopsky met with Brazilian President Jair Bolsonaro, an avid user of the platform. According to the firm's VP, the main subject of the meeting was "freedom of expression." The administrator of a telegram group, "Suck Channel," was sentenced to six years and six months in prison for seven counts of incitement yesterday. Co-founder of NFT renting protocol Rentable World emiliano.eth shared the group Tuesday morning on Twitter, calling out the "degenerate" community, or crypto obsessives that engage in high-risk trading. Select: Settings – Manage Channel – Administrators – Add administrator. From your list of subscribers, select the correct user. A new window will appear on the screen. Check the rights you’re willing to give to your administrator.
from us


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