<div class="float-right">
<span class="language dashboard" data-toggle="dropdown">
<img class="current" src="us-flag.png" />
</span>
<div class="dropdown dashboard">
<a href="javascript:" (click)="setch('en');" class="dropdown-item">
<img src="us-flag.png" alt="" />english </a
>
<a href="javascript:" (click)="setch('it');" class="dropdown-item">
<img src="it-flag.png" alt="" />italian </a
>
</div>
</div>
this is the jQuery implementation:
$('.dropdown-item').on({
'click': function(){
//do other thing
$('.current').attr('src','it-flag.png');
}
});
Using Angular 6, I am seeking a way to rewrite this logic in an Angular-friendly manner without relying on jQuery, although I am not very familiar with it.
I intend to implement this logic in the following lifecycle hook:
ngOnInit() {
//assign from default database language setting
var dbflag = "it";
//assign $('.current').attr('src','it-flag.png');
}
setch(){
//change flag class="current"
}
Do you have any suggestions for rewriting this code using TypeScript in an Angular context?