首先把你的專案改為 ssr
ng add @nguniversal/express-engine
ng 會幫你新建立一些資料,資料結構如下
src/
index.html app web page
main.ts bootstrapper for client app
main.server.ts * bootstrapper for server app
style.css styles for the app
app/ ... application code
app.server.module.ts * server-side application module
server.ts * express web server
tsconfig.json TypeScript base configuration
tsconfig.app.json TypeScript browser application configuration
tsconfig.server.json TypeScript server application configuration
tsconfig.spec.json TypeScript tests configuration
# The files marked with * are new and not in the original tutorial sample.
在來啟動你的專案
npm run dev:ssr
透過 routerLinks 導航時能正常工作,因為它們使用的是原生的連結標籤<a>
響應式表單提供了一種模型驅動的方式來處理表單輸入,其中的值會隨時間而變化。本文會向你展示如何建立和更新基本的表單控制元件,接下來還會在一個表單組中使用多個控制元件,驗證表單的值,以及建立動態表單,也就是在執行期新增或移除控制元件。 form 表單 這裡的 require 建儀是寫在 formGroup 裡面去作理管,才可方便的在 js 中看到何為必填值。 <form [formGroup]="subscribeForm" (ngSubmit)="submit()"> <mat-form-field class="w-full"> <input matInput required type="email" formControlName="email" /> <mat-error> Please enter a valid email address </mat-error> </mat-form-field>
Jul 15, 2024angular 原生的 number 需要特別去看一下 decimaPipe
Jul 15, 2024asdf
Dec 1, 2022開發 Angular 就不能不知道 Angular CLI 這個超級好用的命令列工具,有了這個工具,原本渾沌的開發環境,頓時清晰,許多繁瑣的瑣事,一個命令就搞定!這邊是我自己的操作筆記,讓記憶力不佳的我,有個地方可以方便查詢。 這裡的內容不保證最新,但會盡量持續更新。 最即時的文件請參考 Angular CLI 在 Github 上的文件,例如要查 ng new 這個指令的用法,請參考這個連結。 安裝 建議使用 Node.js 的 npm 套件管理工具來安裝 Angular CLI,請使用以下指令安裝: npm install -g angular-cli
Dec 1, 2022or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up