所以,我定義了一個按鈕屬性陣列:
locationButtons: IButton[] = [
{
label: 'Customer-Hierarchy.LocationActions.SiteVisitButton',
disabled: true,
code: ButtonCode.SiteVisit,
redirectUrl: 'this.onSiteVisitClick()'
},
{
label: 'Customer-Hierarchy.LocationActions.ServiceInstallationButton',
disabled: true,
code: ButtonCode.ServiceInstallation,
redirectUrl: 'this.onServiceInstallClick()'
}
];
當用戶單擊按鈕時,我想呼叫在重定向 Url 道具中定義的函式。
<div *ngFor="let item of locationButtons">
<button ngbDropdownItem [disabled]=item.disabled
(click)=item.redirectUrl>
{{item.label | translate}}
</button>
</div>
uj5u.com熱心網友回復:
您可以將redirectUrl屬性分配給適當的方法:
locationButtons: IButton[] = [
{
...
redirectUrl: this.onSiteVisitClick
},
{
...
redirectUrl: this.onServiceInstallClick
}
];
然后將click事件系結到方法呼叫。
<div *ngFor="let item of locationButtons">
<button ngbDropdownItem [disabled]="item.disabled"
(click)="item.redirectUrl()">
{{item.label | translate}}
</button>
</div>
干杯
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/442469.html
下一篇:使用C#從網頁獲取十進制值
