Angular (Full App) with Angular Material, Angularfire & NgRx 第3章 35节

src\app\auth\signup\signup.component.html

<section class="signup-form">
  <form fxLayout="column" fxLayoutAlign="center center" fxLayoutGap="16px" #f="ngForm" (ngSubmit)="onSubmit(f)">
    <mat-form-field>
      <input type="email" matInput placeholder="Your email" ngModel name="email" email required #emailInput="ngModel" />
      <mat-error>Please input valid email!</mat-error>
    </mat-form-field>
    <mat-form-field>
      <input type="password" matInput placeholder="Your password" ngModel name="password" required minlength="8" #pwInput="ngModel" />
      <mat-hint>Should be at least {{ pwInput.value?.length }} / 8 characters long.</mat-hint>
    </mat-form-field>
    <mat-form-field>
      <input matInput placeholder="Your birthdate" [matDatepicker]="picker" [max]="maxDate" ngModel name="birthdate" required />
      <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
      <mat-datepicker #picker></mat-datepicker>
    </mat-form-field>
    <mat-checkbox ngModel name="agree" required>Agree to Terms and Conditions.</mat-checkbox>
    <button type="submit" mat-raised-button color="accent" [disabled]="f.invalid">Submit</button>
  </form>
</section>

src\app\auth\signup\signup.component.ts

import { Component, OnInit } from '@angular/core';
import { NgForm } from '@angular/forms';

@Component({
  selector: 'app-signup',
  templateUrl: './signup.component.html',
  styleUrls: ['./signup.component.sass'],
})
export class SignupComponent implements OnInit {
  maxDate?: Date;

  constructor() {}

  ngOnInit(): void {
    this.maxDate = new Date();
    this.maxDate.setFullYear(this.maxDate.getFullYear() - 18);
  }

  onSubmit(form: NgForm) {
    console.log(form);
  }
}

src\app\auth\signup\signup.component.sass

.mat-form-field
  width: 420px

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值