I have code which is written in JavaScript code as let input= document.querySelector("#input");
and
input.addEventListener('click', function() {
canvas.getContext('2d').drawImage(input, 0, 0, canvas.width, canvas.height);
let image_data_url = canvas.toDataURL('image/jpeg');
});
I want to write this code in angular how can I convert and use this code in angular9 project anyone please help me
the best way to do it is like this:
<input (click)="clickOnMyInput($event)">
and in your.ts file
clickOnMyInput(e){
this.canvas.getContext('2d').drawImage(e.target, 0, 0, this.canvas.width, this.canvas.height);
let image_data_url = this.canvas.toDataURL('image/jpeg');
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.