Skip to content

Instantly share code, notes, and snippets.

@Kamilnaja
Created January 30, 2024 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kamilnaja/78fc932b3de2adaace353d0b6129ab18 to your computer and use it in GitHub Desktop.
Save Kamilnaja/78fc932b3de2adaace353d0b6129ab18 to your computer and use it in GitHub Desktop.
Struktura klasy
@ViewChild, @ViewChildren, ContentChild
@Inputy @Outputy
readonly observable$, subject
pola publiczne
pola prywatne
constructor()
gettery
ngOnInit
ngAfterViewInit i inne metody lifecycle
metody publiczne
metody prywatne
ngOnDestroy
Przykład
export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
@ViewChild('sidenav') sidenav: any;
readonly isloading$ = new BehaviorSubject<boolean>(false);
userName = 'Ktoś tam';
private tajnePole = 42;
title = 'Diet Tracker';
constructor(private metaTagService: Meta, private titleService: Title) {}
get titleGetter() {
return this.title;
}
ngOnInit(): void {
this.metaTagService.addTags([
{
name: 'keywords',
content: 'Angular SEO Integration, foods, diary, lifestyle',
},
{ name: 'robots', content: 'index' },
{ name: 'author', content: 'Tomasz Sokalski' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ name: 'date', content: '2023-03-08', scheme: 'YYYY-MM-DD' },
{ charset: 'UTF-8' },
]);
this.titleService.setTitle('Diet Tracker');
}
ngAfterViewInit(): void {
throw new Error('Method not implemented.');
}
btnClicked() {
console.log('user has clicked btn');
}
private logDate() {
console.log('date');
}
ngOnDestroy(): void {
console.log('bye');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment