Created
December 9, 2018 16:56
-
-
Save NeelBhatt/bf2c04bb00516e30bdddcc67abf04d53 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
employee-Add.component.ts | |
import { Component, OnInit,Input, ViewChild, ElementRef, EventEmitter, Output } from '@angular/core'; | |
import { NgForm } from '@angular/forms'; | |
import { Employee } from 'src/Models/Employee'; | |
import { Router } from '@angular/router'; | |
import {EmployeeDataService} from '../DataService/EmployeeDataService' | |
@Component({ | |
selector: 'app-employee-add', | |
templateUrl: './employee-add.component.html', | |
styleUrls: ['./employee-add.component.sass'] | |
}) | |
export class EmployeeAddComponent implements OnInit { | |
@Input() cleardata: boolean = false; | |
@Output() nameEvent = new EventEmitter<string>(); | |
objtempemp:Employee; | |
@Input() objemp :Employee=new Employee();; | |
@ViewChild('closeBtn') cb: ElementRef; | |
constructor(private dataservice:EmployeeDataService,private route:Router) { | |
} | |
ngOnInit() { | |
// this.ResetValues(); | |
} | |
ResetValues(){ | |
} | |
Register(regForm:NgForm){ | |
this.objtempemp=new Employee(); | |
this.objtempemp.email=regForm.value.email; | |
this.objtempemp.firstname=regForm.value.firstname; | |
this.objtempemp.lastname=regForm.value.lastname; | |
this.objtempemp.gender=regForm.value.gender; | |
this.dataservice.AddEmployee(this.objtempemp).subscribe(res=>{ | |
alert("Employee Added successfully"); | |
this.TakeHome(); | |
} | |
) | |
} | |
TakeHome(){ | |
this.nameEvent.emit("ccc"); | |
this.cb.nativeElement.click(); | |
this.route.navigateByUrl(''); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment