Closed10

Astro で Angular を使ってみる

YNZTYNZT

ひとまず yarn create astro して yarn astro add @analogjs/astro-angular

見慣れた子たちが自動で追加される。

@analogjs/astro-angular のバージョンは 0.1.0-beta.1

YNZTYNZT

tsconfig.app.json が必要とのことで記事の内容で作成。
tsconfig.json の方にも experimentalDecorators の設定を追加しておいた。

YNZTYNZT

記事のコンポーネントを追加。
お初の standalone component だ。

yarn dev & yarn build してみて表示を確認。

client:load の有無でJS が読み込まれたり読み込まれなかったりするのも動作している。

YNZTYNZT

build した時の HTML を見てみると、body 要素の中に下記の HTML が出力されていた。
(まだ beta)

<html><head></head><body><app-hello ng-version="14.2.0"><p>Hello from Angular!!</p><button>Toggle</button><p>Toggled</p><!----></app-hello></body></html>
YNZTYNZT

styleUrls も動くが、.scss でネスト使用 & yarn dev 時、下記の画像の様に出力された。

YNZTYNZT

よく見たら

Some language features are not available. To access all features, enable strictTemplates in angularCompilerOptions.

と VSCode に言われていたので、tsconfig.app.json に書いてある angularCompilerOptions は tsconfig.json に動かした。

このスクラップは2022/10/12にクローズされました