打开下拉菜单时,我需要更改引导图标
我有这样的代码component.html
<div>
<span dropdown (isOpenChange)="onOpenChange($event)" class="btn-group">
<a href id="basic-link" dropdownToggle (click)="false" aria-controls="basic-link-dropdown">
<img src="./assets/first.svg" *ngIf="!currentLayout && isDropDownOpened">
<img src="./assets/firts_reg.svg" *ngIf="!currentLayout && !isDropDownOpened">
</a>
<ul id="basic-link-dropdown" *dropdownMenu class="dropdown-menu schedule-view" role="menu" aria-labelledby="basic-link">
<li><a class="dropdown-item" (click)="navigate('')">
<img src="./assets/first.svg">
First
</a></li>
</ul>
</span>
</div>
和component.ts
currentLayout: string;
isDropDownOpened = false;
constructor(private router: Router) {}
ngOnInit() {}
navigate(layout) {
this.currentLayout = layout;
this.router.navigate([`/schedule/${layout}`], { skipLocationChange: true });
}
onOpenChange(data: boolean) {
console.log(data);
this.isDropDownOpened = !this.isDropDownOpened;
}
当我单击切换下拉菜单时,控制台中有一次true
和一次false
,并且没有出现下拉菜单。