Notice: file_put_contents(): Write of 17099 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.3314
SWEBDEV Telegram 3314
Метод ngAfterContentInit для управления контентом, переданным через ng-content

В Angular метод ngAfterContentInit является жизненным циклом компонента, который вызывается после инициализации контента, переданного через ng-content. Это позволяет выполнять операции над переданными дочерними элементами после того, как они станут частью DOM компонента.

Пример:
import { Component, ContentChild, AfterContentInit } from '@angular/core';
import { ElementRef } from '@angular/core';

@Component({
selector: 'app-card',
template: `<div class="card"><ng-content></ng-content></div>`
})
export class CardComponent implements AfterContentInit {
@ContentChild('header') header!: ElementRef;

ngAfterContentInit() {
if (!this.header) {
console.warn('Контент заголовка не передан!');
} else {
console.log('Заголовок загружен:', this.header.nativeElement.textContent);
}
}
}

Здесь CardComponent проверяет наличие элемента header и логгирует его содержание при успешной инициализации.

👉 @sWebDev
🔥3👍1



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

Метод ngAfterContentInit для управления контентом, переданным через ng-content

В Angular метод ngAfterContentInit является жизненным циклом компонента, который вызывается после инициализации контента, переданного через ng-content. Это позволяет выполнять операции над переданными дочерними элементами после того, как они станут частью DOM компонента.

Пример:

import { Component, ContentChild, AfterContentInit } from '@angular/core';
import { ElementRef } from '@angular/core';

@Component({
selector: 'app-card',
template: `<div class="card"><ng-content></ng-content></div>`
})
export class CardComponent implements AfterContentInit {
@ContentChild('header') header!: ElementRef;

ngAfterContentInit() {
if (!this.header) {
console.warn('Контент заголовка не передан!');
} else {
console.log('Заголовок загружен:', this.header.nativeElement.textContent);
}
}
}

Здесь CardComponent проверяет наличие элемента header и логгирует его содержание при успешной инициализации.

👉 @sWebDev

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




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

View MORE
Open in Telegram


Telegram News

Date: |

Polls 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.” Users are more open to new information on workdays rather than weekends. As five out of seven counts were serious, Hui sentenced Ng to six years and six months in jail. 3How to create a Telegram channel?
from us


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