I have a ngx-slide-carousel in homecomponent.html,
<div class="row p-4" id="sixtwo">
<ngx-slick-carousel class="carousel"
#slickModal="slick-carousel"
[config]="slideConfig" >
<div ngxSlickItem class="slide" *ngFor="let slide of slides" >
<div class="sixcont">
<img src="{{ slide.img }}" alt="" width="95%">
<button type="button" class="btn btn-info btn-sm " data-toggle="modal" attr.data-target="{{slide.modelname}}">quick preview {{ slide.des}}</button>
</div>
<h1>{{ slide.des}}</h1> <div class="fa fa-star checked"></div>
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<div class="fa fa-star checked"></div><br>
<button type="button" class="btn btn-info btn-sm" data-toggle="modal">Add to cart</button>
</div>
</ngx-slick-carousel>
</div>
and its array in homecomponent.ts like,
export class HomepageComponent implements OnInit {
@ViewChild('carousel') carousel: any;
constructor() {
}
slides = [
{img:"",des:"Soft Drinks",modelname:"#myModal",modelnameid:"myModal"},
{img: "",des:"BOOKS",modelname:"#myModal2",modelnameid:"myModal2"},
{img: "",des:"Cloths",modelname:"#myModal3",modelnameid:"myModal3"}
// ...and so on...
];
];
slideConfig = {
slidesToShow: 6,
slidesToScroll: 1,
arrows:true,
dots:true,
infinite: true,
autoplay: true,
autoplaySpeed: 8000,
speed: 1500}
ngOnInit(): void {
}
}
and the model code inn home.compoent.html:
<div *ngFor="let slide of slides" class="modal fade" id="{{slide.modelnameid}}" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<div class="row"><div class="col-md-6">
<h1>About This Product !!!!!!!!</h1>
<img src="{{slide.img}}" >
<br>
</div><div class="col-md-6" >
<h1>About This Product !!!!!!!! {{slide.modelname}}</h1>
//this button click
<button type="button" data-dismiss="modal" routerLink="/aboutproduct" routerLinkActive="active" > Click to know about this product</button>
</div></div></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
i need to open a component on button click (mentiond as //this btn click) with slide.des ,slide.img as data..
i tried <app-about [name]="slide.des"> in that model set of code..but it is opening that component in home component. i need to redirect to that about component with slide.des,slide.img ....as data.