I have a problem on getting my function inside the OnClick event function to work. What I am trying to achieve is to open any image inside the HTMLCollection with the PhotoViewer plugin. Here's my code so far.
@ViewChild('newscontainer') newscont;
constructor(
private photoViewer: PhotoViewer
) {}
var imgHtml = this.newscont.nativeElement.getElementsByTagName('img');
for(let img of imgHtml) {
img.onclick = function() {
if(img.src.indexOf('http://localhost')) {
console.log(img.src)
this.photoViewer.show(img.src)
}
}
}
I'm getting the Runtime Error. Cannot read property 'show' of undefined.
I managed to get the url of the image and is shown on the console log, but the photoViewer doesn't seem to recognize the injected PhotoViewer so I'm thinking that it cannot be read that way.