Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, OnInit, ViewChild } from '@angular/core';
- import { Router } from '@angular/router';
- import { FormBuilder, FormGroup, Validators } from '@angular/forms';
- import { MatSnackBar } from '@angular/material';
- import { emailValidator, matchingPasswords } from '../../theme/utils/app-validators';
- import { DataService } from './../../../services/data.service';
- @Component({
- selector: 'app-sign-in',
- templateUrl: './sign-in.component.html',
- styleUrls: ['./sign-in.component.scss']
- })
- export class SignInComponent implements OnInit {
- @ViewChild('sidenav') sidenav: any;
- loginForm: FormGroup;
- registerForm: FormGroup;
- constructor(public formBuilder: FormBuilder, public router:Router, public snackBar: MatSnackBar, public ds: DataService) { }
- ngOnInit() {
- this.loginForm = this.formBuilder.group({
- 'email': ['', Validators.compose([Validators.required, emailValidator])],
- 'password': ['', Validators.compose([Validators.required, Validators.minLength(6)])]
- });
- this.registerForm = this.formBuilder.group({
- 'name': ['', Validators.compose([Validators.required, Validators.minLength(3)])],
- 'email': ['', Validators.compose([Validators.required, emailValidator])],
- 'password': ['', Validators.required],
- 'confirmPassword': ['', Validators.required]
- },{validator: matchingPasswords('password', 'confirmPassword')});
- this.sPartijViaID("5bfbd6ef7e04b021103c3d28")
- this.sEmailViaID("5c1231507e04b02308c16ff7")
- }
- public onLoginFormSubmit(values:Object):void {
- if (this.loginForm.valid) {
- this.router.navigate(['/products']);
- }
- }
- public onRegisterFormSubmit(values:Object):void {
- if (this.registerForm.valid) {
- this.snackBar.open('You registered successfully!', '×', { panelClass: 'success', verticalPosition: 'top', duration: 3000 });
- }
- }
- Partij;
- Email;
- sGebruiker = "";
- sPartijViaID(_id){
- let req = {
- sToken: "",
- _id: _id
- }
- this.ds.sPartijViaID(req).subscribe(res => {
- this.Partij = res
- console.log("Response van sPartijlViaID", res)
- })
- }
- on_iPartij(){
- delete this.Partij["_id"]
- let req = {
- sToken: "",
- Partij: this.Partij
- }
- console.log("Partij", this.Partij)
- this.ds.iPartij(req).subscribe(res => {
- console.log("Response van iPartij", res)
- })
- }
- sEmailViaID(_id){
- let req = {
- sToken: "",
- _id: _id
- }
- this.ds.sEmailViaID(req).subscribe(res => {
- this.Email = res
- console.log("Response van sEmailViaID", res)
- })
- }
- on_iEmail(){
- let req = {
- sToken: "",
- Email: this.Email
- }
- console.log("Partij", this.Email)
- this.ds.iEmail(req).subscribe(res => {
- console.log("Response van iEmail", res)
- })}
- // var email = require("./path/to/emailjs/email");
- // var server = email.server.connect({
- // user: "username",
- // password:"password",
- // host: "smtp.your-email.com",
- // ssl: true
- // });
- // // send the message and get a callback with an error or details of the message that was sent
- // server.send({
- // text: "i hope this works",
- // from: "you <username@your-email.com>",
- // to: "someone <someone@your-email.com>, another <another@your-email.com>",
- // cc: "else <else@your-email.com>",
- // subject: "testing emailjs"
- // }, function(err, message) { console.log(err || message); });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement