在两个不同的组件有限的数据例如如何显示在角2
我已在其中所有图像从JSON示出共享组件称为图像画廊制成。现在我在主页和图库页面中使用这个共享组件。在主页上,我想先显示8张图像,并在图库页面中显示所有图像。
共享组件
@Component({
selector: 'app-gallery',
templateUrl: './gallery.component.html'
})
export class GalleryComponent implements OnInit {
//getting images data from my service
}
HTML是共享的组件是
<div class="col-md-3 col-sm-6" *ngFor="let image of gallery">
<div class="gallery-img">
<a href="">
<img src="{{gallery.images[0]}}">
</a>
</div>
</div>
主页的HTML组件
<app-gallery></app-gallery> //Here i want show 8 images only
图库组件页
<app-gallery></app-gallery> // Here i want to show all images from gallery
你可以发布你的组件的代码? –
什么是共享组件,它是什么选择器,它在哪里使用? –