I want to change image based on click


#1

I want to change image based on click . i have a two image
One
red-button
another one is
green-button

i want to do that when user click on lock button will be show the unlock and when user click on unlock button will be show the lock button

how can i do that please check it sir.


#2

Hi@flycoders_sourav
You can do like this
HTML

     <img src="{{myimage}}" (click)="addEvent();">

Ts

declare
public myimage = 'https://discourse-cdn-sjc1.com/ionicframework/uploads/default/original/3X/c/f/cf7af661f0bae7cca915258f2b8d6b3937fccda4.png';
  addEvent(){
  	if(this.myimage=='https://discourse-cdn-sjc1.com/ionicframework/uploads/default/original/3X/c/f/cf7af661f0bae7cca915258f2b8d6b3937fccda4.png')
  	{
  		this.myimage='https://discourse-cdn-sjc1.com/ionicframework/uploads/default/original/3X/e/5/e5001dfda25e215c0304eb79a9637d7fbd53ca73.png';
  	}else{
		this.myimage = 'https://discourse-cdn-sjc1.com/ionicframework/uploads/default/original/3X/c/f/cf7af661f0bae7cca915258f2b8d6b3937fccda4.png';
  	}
  	
  }

#3

Great. its working fine