ng generate component emps
ng generate component empdet
//...
export class EmployeesComponent implements OnInit {
employeeName = "Erős István";
constructor() { }
ngOnInit(): void {
}
}
employees works!
import { Component, Input, OnInit } from '@angular/core';
//...
export class EmpldetComponent implements OnInit {
@Input() employeeName = '';
constructor() { }
ngOnInit(): void {
}
}
empldet works!
Név: {{employeeName}}
Teljes:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-emps',
templateUrl: './emps.component.html',
styleUrls: ['./emps.component.css']
})
export class EmpsComponent implements OnInit {
actName = "Erős István";
constructor() { }
ngOnInit(): void {
}
}
emps works!
import { Component, Input, OnInit } from '@angular/core';
@Component({
selector: 'app-empdet',
templateUrl: './empdet.component.html',
styleUrls: ['./empdet.component.css']
})
export class EmpdetComponent implements OnInit {
@Input() employeeName = '';
constructor() { }
ngOnInit(): void {
}
}
empdet works!
Név: {{employeeName}}
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-emps',
templateUrl: './emps.component.html',
styleUrls: ['./emps.component.css']
})
export class EmpsComponent implements OnInit {
employeeArray = [ 'Kerek György', 'Rendes Imre' ];
constructor() { }
ngOnInit(): void {
}
addEmployee(newEmployee: string) {
this.employeeArray.push(newEmployee);
}
}
emps works!
-
{{empl}}
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
@Component({
selector: 'app-empdet',
templateUrl: './empdet.component.html',
styleUrls: ['./empdet.component.css']
})
export class EmpdetComponent implements OnInit {
@Output() newEmployeeEvent = new EventEmitter();
constructor() { }
ngOnInit(): void {
}
addNewEmployee(value: string) {
this.newEmployeeEvent.emit(value);
}
}
empdet works!