Skip to content

Instantly share code, notes, and snippets.

@debugmodedotnet
Created September 5, 2019 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save debugmodedotnet/903bad53fbe113419b6ddfde19f8b75d to your computer and use it in GitHub Desktop.
Save debugmodedotnet/903bad53fbe113419b6ddfde19f8b75d to your computer and use it in GitHub Desktop.
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