Angular lightbox:无法绑定到“data-lightbox”,因为它不是“a”的已知属性

2024-01-05

我读过《角》。它说如果你想绑定一个属性,它应该用 [] 包裹。所以我做了什么,但我收到了错误。知道我做错了什么吗?

我的要求是 data-lightbox 的值是我从另一个组件(父组件)设置/发送的值

图像显示.component.ts

@Component({
    selector: 'app-image-display',
    templateUrl: './image-display.component.html',
    styleUrls: ['./image.component.css']
  })
  export class ImageDisplayComponent implements OnInit {
    @ViewChild('inspImage') image: ElementRef
    @Input() inspection: LineSideInspection
    inpsectionId: number;
    santizer: DomSanitizer

    constructor(private imageService: ImageDisplayService, private sanitizer: DomSanitizer) {}

    ngOnInit() {
      this.getMyImage('/getimage/' + this.inspection.id );
        this.inpsectionId = this.inspection.id;
    }
}

图像显示.component.html

<a [href]="sanitize(inspImage.src)" [data-lightbox]="inspectionId" data-title="inspect.inspectionDescription"> 
    <img #inspImage width="110px" height="95px">
</a>

包.json:

"lightbox2": "^2.10.0",

尝试使用 -

<a [href]="sanitize(inspImage.src)" [attr.data-lightbox]="inspectionId" data-title="inspect.inspectionDescription"> 
    <img #inspImage width="110px" height="95px">
</a>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Angular lightbox:无法绑定到“data-lightbox”,因为它不是“a”的已知属性 的相关文章

随机推荐