import { Component , OnInit } from '@angular/core' ; import { FormBuilder , FormGroup , Validators } from '@angular/forms' ; import { Store } from '@ngxs/store' ; import { Account } from 'src/app/store' ; @ Component ( { selector : 'app-signup' , templateUrl : './signup.component.html' , styleUrls : [ './signup.component.css' ] , } ) export class SignupComponent implements OnInit { signupForm : FormGroup ; constructor ( private formBuilder , private store ) { this . signupForm = this . formBuilder . group ( { name : [ '' , [ Validators . required ] ] , email : [ '' , [ Validators . required , Validators . email ] ] , password : [ '' , Validators . required ] , } ) ; } ngOnInit ( ) { } handleSignup ( ) { console . log ( 'Signing up' ) ; let payload = { email : this . signupForm . value . email , password : this . signupForm . value . password , name : this . signupForm . value . name } ; this . store . dispatch ( new Account . Signup ( payload ) ) ; } }