Angular에서는 TypeScript의 Decorator을 이용하여 Annotation을 제공하고 있다.( TypeScript문서에서는 실험적기능이라고 소개하고 있어서 어떻게 최종적으로 정의 될지는 아직 모르겠다.) 아직 Angular에서는 class에 대한 decorator만을 사용하고 있는 것으로 보인다. Method에 대한 decorator는 계속적으로 변하고 있는 것으로 파악된다.(인터넷에 있는 예제 샘플이 계속 변하고 있는 것으로 파악된다.)
import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.sass'] }) export class AppComponent { title = 'Carpenter'; }
Component 데코레이터는 Angular의 컴포넌트를 기술하여 준다.
<app-root></app-root>
<div app-root"></div>
template를 이용하여 html작성한다.styles를 이용하여 css를 작성한다.import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) export class EmployeeService { constructor() { } getEmployees(){ return [ { id: 3, name: "둘리", age: 100030 }, { id: 4, name: "고길동", age: 30 }, { id: 5, name: "희동이", age: 30 }, { id: 5, name: "고철수", age: 30 }, ]; } }