![](/img/trans.png)
[英]How can I get the height/offset of an element after it has 'skew' transform has been applied with JS/jQuery?
[英]Angular, How to get classes by Jquery after getting data from server and *ngFor has been applied for them?
我在 Angular 中使用 Jquery 和 typescript,我想獲取由 ngFor 循環生成的所有類。我正在構建一個產品站點......產品,我正在為它們應用 ngFor,在這個 ngFor 中我使用 class 名稱 imagePopup,當我運行此代碼時 let x = $('.imagePopup'); 我得到 x.length = 0; 我沒有從 ngFor 循環中獲得課程。我怎樣才能獲得所有課程?
我的代碼:
ngOnInit(): void {
this.productsSubjectSubscribe = this.localProductService.myProductsSubject.subscribe(x=> {
this.myProducts = x;
let y = $('.open-poup-image');
console.log(y);
});
}
console.log(y) 獲取長度 = 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>
如果我可以提供建議,請不要將 jQuery 與 Angular 一起使用。 它會導致很多問題:/ 向我們展示您的代碼,我們會嘗試找出如何解決它:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.