====== Component ====== Angular에서 UI를 표현하기 위해서 사용한다. * [[angular:component:communication|Communication]] ===== angular CLI ===== ng generate **component** [//option//] ng g **component** [//option//] ng g **c** [//option//] [[https://angular.kr/cli/generate#component|Angular.Io참조]] ===== Component Annotation ===== Angular에게 Component를 알려주는 Annotation은 @Component라는 Annotation을 사용한다. -sample import { Component, OnInit } from '@angular/core'; import { AboutComponent } from './about/about.component'; @Component({ selector: 'app-test', templateUrl: './test.component.html', styleUrl: ['./test.component.css'] }) export class TestComponent implements OnInit { constructor() { } ngOnInit() { } } ===== selector ===== 3가지 유형을 가진다. === Type 1. 'app-test' === Template html에서 customer tag로써 표현 === Type 2. '.app-test' === Template html에서 class로 표현
=== Type 3. '[app-test]' === Template html에서 Property로 표현
===== template ===== 직접 inline template를 입력 template: '
Inline template
',
template: `
Inline template
`,
===== styles ===== Inline template styles: ` div{ color: red } `,