I am using Jquery in Angular with typescript, I want to get all the classes that have been generated by ngFor loop.. I am building a products site... I am getting the products from node.JS Server... after I get the Products, I am applying ngFor for them, In this ngFor I am using a class name imagePopup, when I run this code let x = $('.imagePopup'); I get x.length = 0; I'm not getting the classes from the ngFor loop.. How can I get all of them?
my Code:
ngOnInit(): void {
this.productsSubjectSubscribe = this.localProductService.myProductsSubject.subscribe(x=> {
this.myProducts = x;
let y = $('.open-poup-image');
console.log(y);
});
}
console.log(y) gets length = 0
<div *ngFor="let item of myProducts;index as i" class="item" [id]="'item_'+item._id">
<div class="item_img">
<a class="open-poup-image"
[href]="'src-to-image.jpg">Open
image</a>
<img
[src]="src-to-image.jpg">
</div>
</div>
If I can give advice, don't use jQuery with Angular. It causes lots of problems:/ Show us your code, and we try to figure out, how can we solve it:)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.