[Book] Clean Code

書名: Clean Code: A Handbook of Agile Software Craftsmanship

作者: Robert C. Martin

Continue reading [Book] Clean Code

Advertisements

Angular 4 Jot Down Cont.

XXX.component.ts

// 宣告為Element
@Component({
  selector: 'app-server',
  ......
})
<app-server></app-server>

// 宣告為Attribute
@Component({
 selector: '[app-server]',
 ......
})

// 宣告為Style Class 
@Component({
 selector: '.app-server',
 ...... 
})

styleURL vs styles

@Component({
 styleUrls: ['./server.component.css'],
 ......
})

@Component({
 styles: [`
   h2 {color: DarkGreen}; 
 `], → 多行使用back quote
 ......
})

@Component({
 styles: ['h2 {color: DarkGreen};'], → 單行可使用single quote
 ......
})

Syntax

DataBinding

String Interpolation

// ts
export class xxxComponent {
  title = 'This is Title';
}

// HTML
{{ Variable Name }}
ex. {{ title }}

Property Binding

[property]="data"
ex. <p [@myProperty]="state" .../>

Event Binding

(event)="expression"
ex. <p (click)="clickMe()" .../>