Created
September 5, 2019 11:58
-
-
Save debugmodedotnet/903bad53fbe113419b6ddfde19f8b75d 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
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