我有此HTML代码:
<div class="btn-group" role="group" aria-label="Basic example" *ngFor="let techlist of technology">
<button type="button" class="btn btn-secondary" (click)="resList()">{{techlist.TechnologyRouteTitle}}</button>
</div>
该技术具有视图模型:
public ComponentTypeId: number;
public ComponentTypeTitle: string;
public TechnologyRouteId: number;
现在有4个元素。他们有一个独特的技术奖。通过单击其中一个,我需要加载一系列技术列表。我有这个功能:
resList(): void {
this.TestService.getResearchList(this.filterResearchList)
.then(response => {
this.technology = response.Object;
});
}
this.filterresearchList具有这样的视图模型:
public CompanyId: number;
public TechnologyRouteKey: string;
公司的ID总是相同的,但是根据您按下的按钮,需要更改TechnologyRoutekey,该如何执行此操作?已经花了一个小时了,无法正常工作。看哪种方式?
如果要传递值,则应将单击函数作为参数
传递给(click)="resList(argument)" //in template html file
这意味着如果我正确,应该像这样(检查点击功能我通过了路由ID(
<div class="btn-group" role="group"
aria-label="Basic example" *ngFor="let techlist of technology">
<button type="button" class="btn btn-secondary"
(click)="resList(techlist.TechnologyRouteId)">
{{techlist.TechnologyRouteTitle}}</button>
</div>
和TS文件
resList(argument): void {
}