Gồm 3 thành phần chính:
main.ts => bootstrapModule: Khởi động root module
@Component:
Angular # AngularJS
TypeScript gồm các type:
Type Assertion:
Link download: https://nodejs.org/en/blog/release/v12.13.0/
//kiểm tra node node --version
npm install glabal @angular/cli //hoặc ngắn gọn npm i g @angular/cli
//kiểm tra angular cli ng --version
npm init --y
npm i -D typescript //-d == --save-dev
npx tsc --init //chạy build ts => js npx tsc
ng new tenDuAn //route => No // => css
ng serve -o
<tenComponent><schematics>.ts
schematics có thể là:
ng generate component duongDan/TenComponet //hoặc ngắn gọn ng g c duongDan/TenComponet
component to template
{{ tenBien }}
src = "tenBien" //hoặc [src] = "tenBien" //src có thể là các thuộc tính khác của element
[style.color] = "tenBien" [style.background] = "tenBien" //viết gọn [ngStyle] = { color: tenBien, background: tenBien } //có thể thay object phía sau thành một biến
[class.tenClass] = true/false; /* true: có thêm class này false: không thêm class này */ //hoặc ngắn gọn [ngClass] = { tenClass: true, tenClass: false }
template to component
(tenSuKien) = "tenHam()" (click) = "handleButtonClick()"