0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【今日から携わる】Angularを試してみた(Angular入門・チュートリアル)

Last updated at Posted at 2019-02-04

Angularを試してみたので共有します。
jsフレームワーク未経験の方でもできる、Angular公式チュートリアルをやってみました。
<作業時間>
1回目:10分
2回目:3分

Angularチュートリアル
https://angular.jp/guide/quickstart

このチュートリアルでできること

・Angularをインストール
・新規プロジェクト作成
・ブラウザで確認する
・編集する(タイトルの文言&スタイル変更)
スクリーンショット 2019-02-05 0.45.01.png

(1)Angular CLIのインストール

Nodeのバージョンを確認

node -v
//バージョン8.xまたは10.xが必要

Angularをグローバルインストール

npm install -g @angular/cli

(2)新規プロジェクト作成

ローカルに新規フォルダを作成する。
↓↓↓
ng new my-app
//新しいワークスペースと初期アプリケーションプロジェクトを作成する
↓↓↓
Enterキーを押してデフォルト値を受ける

(3)アプリケーションをサーブ

cd my-app
//ワークスペースフォルダ(my-app)に移動
↓↓↓
ng serve --open
//--openオプションを付けてCLIコマンド ng serve を使用してサーバーを起動
↓↓↓
http://localhost:4200/
//ブラウザで開く
スクリーンショット 2019-02-05 0.27.52.png

(4)Angularコンポーネントを編集

my-appフォルダをエディタで開く

app.component.ts
import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'my-app';
}

//1. src/app/app.component.tsを開く
//2. title プロパティを 'my-app'から 'My First Angular App'に変更

↓変更する

src/app/app.component.ts
import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'My First Angular App!';
}

ブラウザで確認する
http://localhost:4200/

スクリーンショット 2019-02-05 0.40.38.png

h1のスタイルをCSSで変更する

src/app/app.component.css
h1 {
    color: #369;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 250%;
  }
スクリーンショット 2019-02-05 0.45.01.png

”入門”おわり

【今日から携わる】Angularを試してみた(Angular基礎・ツアー・オブ・ヒーローズ チュートリアル)

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?