BLANK, NULL AND BLACK

ngStyle

ANGULAR2017. 11. 1. 00:12

인라인 타입

<p [ngStyle]="{color: 'red', backgroundColor: 'blue'}">

 예제 입니다.

</p>



메서드타입

<p [ngStyle]="{color: 'red', backgroundColor: getBackgroundColor()}">

ts 파일에서 메서드 생성


getBackgroundColor() : string {

    //return "black"; //문자열 반환

    return (new Date()).getSeconds() % 2 == 0 ? "green" : "lime"; // 새로고침 시점이 짝수 초일때 초록색, 아닐때 라임색

}




## 정리 필요

'ANGULAR' 카테고리의 다른 글

Angular 4  (0) 2017.10.31