picture-table.component.ts
showPicture(picture: AccessApictures){
console.log(picture.filename);
let pictureDialog = this.dialog.open(PictureModalComponent,
{ data: {
id: picture.id,
caption: picture.caption,
url: picture.filename,
servDate: picture.servDate,
servNum: picture.aservrecno,
}
}
);
}
onPreviousClick(id: number, index: number, picture: AccessApictures) {
for (let id in this.pictures){
return [index -= 1];
}
picture-modal.html
<h1 mat-dialog-title>Service date: {{model.servDate}}
<br>
Service number: {{model.servNum}}</h1>
<div mat-dialog-content>
<img class="img" src= {{model.url}}/>
<p><strong>Caption:</strong> {{model.caption}}</p>
</div>
<div mat-dialog-actions>
<button mat-button (click)='onPreviousClick()'>Previous </button>
<button mat-button (click)='onNextClick()'>Next</button>
<button mat-button mat-dialog-close>Close</button>
</div>
我编辑了我的问题。我正在尝试使html上的上一个按钮转到数组中的上一个图像
答案 0 :(得分:0)
您需要在PreviousClick期望的地方传递2个参数(id和index)。
应该是
<button mat-button (click) ='onPreviousClick(1,1)'>Previous </button>
或id和索引是什么
答案 1 :(得分:0)
您的函数签名错误。
如果您不想向其传递任何值,则应提供如下默认值:
onPreviousClick(id = 0, index = 0) {
console.log(id);
}
请注意,由于默认值为0,TypeScript会推断类型编号,因此您无需定义类型。