Skip to content
This repository was archived by the owner on Aug 24, 2020. It is now read-only.

Commit 07bdfee

Browse files
Merge pull request #5 from fobaz/patch-2
Update with a reference to the card instead of retrieving it in the stack using his nativeElement
2 parents 43dc3ca + 3e70782 commit 07bdfee

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/app/modules/ionic-swing/components/swing-card.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import {Card} from '../interfaces/swing';
1010
`
1111
})
1212
export class SwingCardComponent implements OnInit {
13+
private card:Card;
1314
constructor(
1415
private elmentRef: ElementRef,
1516
private swingStack: SwingStackComponent) {
1617
}
1718

1819
ngOnInit() {
19-
this.swingStack.addCard(this);
20+
this.card = this.swingStack.addCard(this);
2021
}
2122

2223
getElementRef() {
@@ -28,6 +29,6 @@ export class SwingCardComponent implements OnInit {
2829
}
2930

3031
getCard(): Card {
31-
return this.swingStack.stack.getCard(this.getNativeElement());
32+
return this.card;
3233
}
3334
}

src/app/modules/ionic-swing/components/swing-stack.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class SwingStackComponent implements AfterContentInit {
5353
addCard(card: SwingCardComponent) {
5454
this.cards.push(card);
5555
if (this.stack) {
56-
this.stack.createCard(card.getNativeElement());
56+
return this.stack.createCard(card.getNativeElement());
5757
}
5858
}
5959

0 commit comments

Comments
 (0)