Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import { EventEmitter, Component, OnInit, Input, OnChanges, ChangeDetectionStrategy, SimpleChange, Output } from '@angular/core';
@Component({
selector: 'app-child',
templateUrl:'app-child.component.html',
styleUrls: ['./app-child.component.css']
})
export class AppChildComponent implements OnInit, OnChanges {
@Input() tshirt ;
quantity;
error = false;
@Output() cancelevent = new EventEmitter();
@Output() buyevent = new EventEmitter();
ngOnChanges(): void {
}
buy(){
if(this.quantity){
if(this.quantity > this.tshirt.quanity){
alert("not avaiable");
}
else{
this.tshirt.quanity = this.tshirt.quanity - this.quantity;
this.buyevent.emit(this.tshirt);
}
}
}
cancel(){
this.cancelevent.emit(false);
}
ngOnInit(): void {
console.log("init");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.