본문 바로가기
FE/Angular

4. Angularでのデータ管理の基礎 Directive

by Birthmark 2022. 1. 25.

参考ページ

 

Angular入門 未経験から1ヶ月でサービス作れるようにする その4. モデルとループと分岐と - Qiita

前回は、複数ページを作ってページ遷移を試しながら、ルーティングの基礎を学びました。 本記事では、 Angularでのデータ管理の基礎 モデルクラスの作成 Angularのディレクティブ基礎 HTMLで

qiita.com

Directive 지시자 정리

 

[Angular] Directive 지시자 정리

Angular2 버전 이후를 기준으로 정리한 글입니다. 앵귤러에는 세가지 지시자(directive)가 있다. 컴포넌트 - 템플릿을 가지는 지시자 구조 지시자 - DOM 요소를 동적으로 추가하거나 제거하는 지시자

lucaskim.tistory.com

ngOnInit()

초기화후에 호출되는 메소드

API에서 데이터를 불러오는 작업은 없으니까 임의로 setTimeout사용하여 3초후에 products에 데이터를 넣도록 한다.

product-detail.component.ts
product-list.component.ts

*ngIf

API에서 데이터를 취득하기 전과 후로 화면을 분기하고 싶은 경우 사용

else의미 ng-template

*ngFor

product-list.component.html

 

switch

구조 디렉티브

 

(Angular) Structural Directive 구조 디렉티브

구조 디렉티브(Structural Directive)는 DOM 요소를 추가, 삭제하여 DOM 구조를 조작하는 역할을 수행하는 디렉티브입니다.

medium.com

Unhovered 는 template name과 일치하며 앞에 #붙이면 됨.

 

How can I use "*ngIf else"?

I'm using Angular and I want to use *ngIf else (available since version 4) in this example: <div *ngIf="isValid"> content here ... </div> <div *ngIf="!isValid"...

stackoverflow.com

'FE > Angular' 카테고리의 다른 글

5. Typescript Basic, Service class  (0) 2022.01.26
compile error/intall node-sass/@angular-devkit  (0) 2022.01.25
3. Routing 화면전이  (0) 2022.01.24
2. Structure of Angular Project  (0) 2022.01.24
1. 프로젝트 생성, 구성요소추가, 빌드  (0) 2022.01.24

댓글