在我的应用程序中,我添加:
"@ngx-gallery/core": "^4.0.3","@ngx-gallery/gallerize": "^4.0.3","@ngx-gallery/lightbox": "^4.0.3",
我从API中读取了一个图像列表,并将其作为ImageItem列表放在了this.items中,但是在该页面中,灯箱不起作用! 这是我在ts中的方法:
GetGallery() {
this.onlinesaleService.GetGalleryImages().subscribe((data: any[]) => {
debugger;
this.items = data['Result'].map(item => new ImageItem({ src:this.root+item.ImageName,thumb: this.root+item.ImageName,textProperty:item.Title }));
this.galleryItem=data['Result'];
const lightboxRef = this.gallery.ref('lightbox');
lightboxRef.setConfig({
imageSize: ImageSize.Cover,thumbPosition: ThumbnailsPosition.Top
});
lightboxRef.load(this.items);
});
}
这是我的html代码:
<a (click)="lightbox.open(0)"> gallery</a>
这是调试器中的结果:
这是结果:
这是package.json代码:
{
"name": "xelle-ui","version": "0.0.0","scripts": {
"ng": "ng","start": "ng serve","build": "ng build","test": "ng test","lint": "ng lint","e2e": "ng e2e"
},"private": true,"dependencies": {
"@angular/animations": "^8.2.13","@angular/cdk": "^8.2.3","@angular/common": "~8.2.8","@angular/compiler": "~8.2.8","@angular/core": "~8.2.8","@angular/forms": "~8.2.8","@angular/material": "^8.2.3","@angular/platform-browser": "~8.2.8","@angular/platform-browser-dynamic": "~8.2.8","@angular/router": "~8.2.8","@ngx-gallery/core": "^4.0.3","@types/jquery": "^3.3.31","angular-bootstrap-lightbox": "^0.12.0","angular-material": "^1.1.20","core-js": "^2.5.7","datatables.net": "^1.10.20","hammerjs": "^2.0.8","ngx-gallery": "^5.10.0","rxjs": "~6.4.0","sweetalert2": "^8.18.6","tslib": "^1.10.0","zone.js": "~0.9.1"
},"devDependencies": {
"@angular-devkit/build-angular": "~0.803.6","@angular/cli": "~8.3.6","@angular/compiler-cli": "~8.2.8","@angular/language-service": "~8.2.8","@types/node": "~8.9.4","@types/jasmine": "~3.3.8","@types/jasminewd2": "~2.0.3","codelyzer": "^5.0.0","jasmine-core": "~3.4.0","jasmine-spec-reporter": "~4.2.1","karma": "~4.1.0","karma-chrome-launcher": "~2.2.0","karma-coverage-istanbul-reporter": "~2.0.1","karma-jasmine": "~2.0.1","karma-jasmine-html-reporter": "^1.4.0","protractor": "~5.4.0","ts-node": "~7.0.0","tslint": "~5.15.0","typescript": "~3.5.3"
}
}