Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 基于单击的thumb更改完整图像无效,方法正在使用中_Angular_Angular7 - Fatal编程技术网

Angular 基于单击的thumb更改完整图像无效,方法正在使用中

Angular 基于单击的thumb更改完整图像无效,方法正在使用中,angular,angular7,Angular,Angular7,我已经在Angular中创建了一个gallery应用程序,它显示3个拇指和一个大图像。根据点击的拇指,完整图像应该-,但不会更改-数据和方法在服务级别上一级。 当i console.log fullImage on images.component.ts时,您的多媒体资料服务中需要例如ReplaySubject: subject = new ReplaySubject<string>(1); onDislayImage = (i: number) => { this.disp

我已经在Angular中创建了一个gallery应用程序,它显示3个拇指和一个大图像。根据点击的拇指,完整图像应该-,但不会更改-数据和方法在服务级别上一级。
当i console.log fullImage on images.component.ts时,您的多媒体资料服务中需要例如ReplaySubject:

subject = new ReplaySubject<string>(1);

onDislayImage = (i: number) => {
this.displayedImage = this.imagesDomain + this.imagesNumber[i];
this.subject.next(this.displayedImage);
}

yourSubject(): ReplaySubject<any> {
return this.subject;
}

别忘了取消对destroy的订阅。

谢谢。经过一些阅读和学习,我决定从以下内容开始:``activeImage=newsubject();this.activeImage.next(this.displayedImage=this.imagesDomain+this.imagesNumber[i])```
import { Component, OnInit, OnDestroy } from '@angular/core';
import { GalleryService } from '../gallery.service';

@Component({
  selector: 'app-images',
  templateUrl: './images.component.html',
  styleUrls: ['./images.component.scss']
})
export class ImagesComponent implements OnInit, OnDestroy {
fullImage: string;
  constructor(private imagesService: GalleryService) {  }

  ngOnInit() {
    this.fullImage = this.imagesService.displayedImage;
  }
ngOnDestroy(): void {}
}
subject = new ReplaySubject<string>(1);

onDislayImage = (i: number) => {
this.displayedImage = this.imagesDomain + this.imagesNumber[i];
this.subject.next(this.displayedImage);
}

yourSubject(): ReplaySubject<any> {
return this.subject;
}
this.fullImage = this.imagesService.displayedImage;
this.imagesService.yourSubject().asObservable().subscribe((res) => {
this.fullImage = res;
});