Skip to content

Instantly share code, notes, and snippets.

@takuya-nakayasu
Last active December 8, 2018 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takuya-nakayasu/797d09c60b204d7dcdc2d1beba1602ec to your computer and use it in GitHub Desktop.
Save takuya-nakayasu/797d09c60b204d7dcdc2d1beba1602ec to your computer and use it in GitHub Desktop.
コンポーネントクラスのHTMLファイル
<div class="container">
<mat-card class="login-card">
<mat-card-header>
<mat-card-title class="login-title">アカウント登録</mat-card-title>
</mat-card-header>
<mat-card-content>
<form [formGroup]="nameRegisterForm" (ngSubmit)="onSubmit()" class="login-form">
<!-- 氏名の入力フォーム -->
<mat-form-field class="input-field">
<input matInput placeholder="氏名(姓と名の間にスペースを入力してください)"
id="name" name="name" [formControl]="nameRegisterForm.controls.name" required>
<!-- 必須入力のエラーメッセージ -->
<mat-error *ngIf="nameRegisterForm.controls.name.errors?.required">氏名は必須項目です</mat-error>
<!-- スペースがない場合のエラーメッセージ -->
<mat-error *ngIf="nameRegisterForm.controls.name.errors?.haveBlank">姓と名の間にはスペースを入力してください</mat-error>
</mat-form-field>
<!-- パスワードの入力フォーム -->
<mat-form-field class="input-field">
<input [type]="hide ? 'password' : 'text'" matInput
placeholder="パスワード" id="password" name="password" [formControl]="nameRegisterForm.controls.password" required>
<mat-icon matSuffix (click)="hide = !hide">{{hide ? 'visibility' : 'visibility_off'}}</mat-icon>
<mat-error *ngIf="nameRegisterForm.controls.password.errors?.required">パスワードは必須項目です</mat-error>
</mat-form-field>
<!-- 確認用パスワードの入力フォーム -->
<mat-form-field class="input-field">
<input [type]="hide ? 'confirmPassword' : 'text'" matInput
placeholder="確認用パスワード" id="confirmPassword" name="confirmPassword" [formControl]="nameRegisterForm.controls.confirmPassword" required>
<mat-icon matSuffix (click)="hide = !hide">{{hide ? 'visibility' : 'visibility_off'}}</mat-icon>
<mat-error *ngIf="nameRegisterForm.controls.confirmPassword.errors?.required">確認用パスワードは必須項目です</mat-error>
<!-- パスワードが一致しないときに表示するエラー -->
<mat-error *ngIf="nameRegisterForm.controls.confirmPassword.errors?.notMatchPassword">パスワードが一致しません</mat-error>
</mat-form-field>
<!-- 登録ボタン -->
<button [appDoubleClickPrevention]="isLoading"
type="submit" class="register-button"
mat-raised-button color="primary">登録</button>
</form>
</mat-card-content>
</mat-card>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment