Angular 2 change image src attribute

前端 未结 3 1210
心在旅途
心在旅途 2020-12-17 16:33

Assuming I have the following code:



        
3条回答
  •  时光取名叫无心
    2020-12-17 17:17

    You could pass a reference of your tag using $event and change it's attribute from your typescript code.

    
    

    Or if you want to change something in image tag on another event you could do it like this

    
    

    and then simply access in typescript code like this

    functioninTypeScript(image:any) {
       image.src='path to new image';
    }
    

提交回复
热议问题