我在列表视图中有三个按钮。我需要执行多个按钮单击来触发相同的方法checkInstall。我不知道该怎么做。我已加入有关守则:
html文件:
<ListView [items]="allAppsList" class="list-group">
.......
.......
<StackLayout row="0" col="2">
<Button text= "Install" (tap) ="checkInstall($event, myIndex)" > </Button>
<Button text= "Open" (tap) ="checkInstall($event1, myIndex)" > </Button>
<Button text= "Remove"(tap) ="checkInstall($event2, myIndex)" > </Button>
</StackLayout>
</ListView> ts文件:
checkInstall(args: EventData, index : number) : void {
}对于执行第一个按钮,checkInstall方法工作的fine.But,我不知道如何获得第二个按钮和第三个按钮的按钮id,分别触发检查以处理诸如隐藏和显示按钮之类的功能。
发布于 2017-07-25 15:47:12
$event是一个角关键字,它有输出发出的值,你不能改变它。
<Button text="Install" (tap)="checkInstall($event,1, myIndex)"> </Button>
<Button text="Open" (tap)="checkInstall($event, 2, myIndex)" > </Button>
<Button text="Remove"(tap)="checkInstall($event, 3, myIndex)" > </Button> 可以向方法发送参数。
checkInstall(args: EventData, buttonIndex: number, index : number) : void {
}https://stackoverflow.com/questions/45307724
复制相似问题