Permalink
Browse files

Step 19.23: Added the signup component

  • Loading branch information...
dotansimha authored and DAB0mB committed Sep 27, 2016
1 parent 24471c4 commit da49bb7039ea8378574253e8a3204abbf728f216
Showing with 43 additions and 0 deletions.
  1. +43 −0 client/imports/app/auth/signup.component.ts
@@ -0,0 +1,43 @@
import {Component, OnInit, NgZone} from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { Accounts } from 'meteor/accounts-base';
import template from './signup.component.html';
@Component({
selector: 'signup',
template
})
export class SignupComponent implements OnInit {
signupForm: FormGroup;
error: string;
constructor(private router: Router, private zone: NgZone, private formBuilder: FormBuilder) {}
ngOnInit() {
this.signupForm = this.formBuilder.group({
email: ['', Validators.required],
password: ['', Validators.required]
});
this.error = '';
}
signup() {
if (this.signupForm.valid) {
Accounts.createUser({
email: this.signupForm.value.email,
password: this.signupForm.value.password
}, (err) => {
if (err) {
this.zone.run(() => {
this.error = err;
});
} else {
this.router.navigate(['/']);
}
});
}
}
}

0 comments on commit da49bb7

Please sign in to comment.