lokesh / lightbox2

THE original Lightbox script (v2).
http://lokeshdhakar.com/projects/lightbox2/
MIT License
6.22k stars 1.77k forks source link

Angular2 + lightbox2 #559

Closed Nikolay-Uvarov closed 6 years ago

Nikolay-Uvarov commented 7 years ago

How can I use lightbox2 with Angular2? Sorry for such a dumb question, but I have not found the solution. I installed "npm install lightbox2 --save" photo.component.html

<p *ngIf="!photos"><em>Loading...</em></p>
<div *ngIf="photos">
    <div class="col-sm-12">
        <h2>My photos</h2>
        <div class="col-sm-8">
            <div *ngFor="let photo of photos">
                <img src="{{photo.path}}" width="360" data-lightbox="example-set"/>
            </div>
        </div>
    </div>
</div>

photo.component.ts

import { Component } from '@angular/core';
import { Http } from '@angular/http';

@Component({
    selector: 'photos',
    template: require('./photos.component.html'),
})
export class PhotosComponent {
    public photos: IPhoto[];

    constructor(http: Http) {
        http.get('/api/SampleData/Photos').subscribe(result => {
            this.photos = result.json();
        });
    }
}

interface IPhoto {
    id: number;
    path: string;
    name: string;
}
lokesh commented 6 years ago

Closing out old issues.

If you still need help, please post your question on Stackoverflow. See more details here: http://lokeshdhakar.com/projects/lightbox2/#help

Using Github Issues for bugs only now. Thanks.