Show data based on item clicked

20 views
Skip to first unread message

John Biddulph

unread,
Oct 8, 2019, 5:45:43 AM10/8/19
to Angular and AngularJS discussion
Hi, 

I have a list of packages
I have 2 buttons

button 1 - selects the package and shows which package is selected - GREAT!
button 2 - toggles an ngIf show/hide but shows all content and not the selected package

I would like button 2 to show/hide only the data clicked

<div class="lower-block" (click)="packageSelect(package)">Add Package</div>
<button (click)="toggleCollapse(package)">Show</button>Enter code here...



packageSelect(thispackage: Package): void {
this.selectedPackage = thispackage;
console.log('the selected package is', this.selectedPackage.name);
}

toggleCollapse(thispackage: Package) {
this.isCollapsed = !this.isCollapsed;
}

Sander Elias

unread,
Oct 9, 2019, 11:50:19 PM10/9/19
to Angular and AngularJS discussion
Hi John,

Its hard to help you without seeing your code. For things like this, the best way is to provide a stackbliitz that demonstrates your issue.

Regards
Sander
Reply all
Reply to author
Forward
0 new messages