0
0

More than 1 year has passed since last update.

【Angularアプリケーション開発 #3】新規コンポーネントを作成しよう

Posted at

今回は新規コンポーネントを作成し、AppComponentに組み込んでみましょう。
フッターコンポーネントを作成してみます。

  • FooterComponentを作成します。
    ターミナルでng g component footer と入力して実行します。
    すると↓エクスプローラーにfooterのディレクトリ(中身はcss、html、tsファイル等)が作成されているでしょう。
    スクリーンショット 2022-05-30 0.05.43.png
  • こちらをAppComponentに組み込みます。
    app.component.htmlに<app-footer></app-footer>のタグを書きます。
    スクリーンショット 2022-05-30 0.09.40.png
  • footer.component.htmlにはわかりやすいように<p>フッター</p>とでも書いておきましょう。
    スクリーンショット 2022-05-30 0.13.24.png
  • ターミナルにng serveを打ち込んで実行!
  • http://localhost:4200/を開く。
    フッターの文字列を表示するだけですが、コンポーネントが組み込まれたことがわかります。
    スクリーンショット 2022-05-30 0.15.36.png
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0