[英]Angular: How can I change the value of a property of a component inside an ngFor
[英]How can i make a property value inside an ngfor independent, between two child components?
單擊汽車品牌時,我需要將其顯示在底部,其中包含人的姓名,以及上面單擊的最喜歡的汽車,但是當我單擊一個時,汽車品牌會在所有項目之間重復ngfor。
它的 stackblitz 示例: https ://stackblitz.com/edit/angular-ivy-rjdhkh?devtoolsheight=33&file=src/app/app.component.html
使用字典來保存每個人的值,並使用他們的名字作為鍵。 請參閱編輯過的 stackblitz。
https://stackblitz.com/edit/angular-ivy-pachaq?file=src/app/app.component.ts
只需在渲染 ngfor 中的每個組件時使用輸入。 https://angular.io/guide/inputs-outputs
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.