Situation: I am using FirebaseObjectObservable to populate my Ionic 2 (rc0) template. Template Code:
<p>{{(course | async)?.description}}</p> <button ion-button dark full large (click)="openDeckOnBrowser(course.deckUrl)"> <ion-icon name='cloud-download'></ion-icon> <div>View Deck</div> </button>
TS file
this.course = this.af.database.object('/bbwLocations/courses/' + courseId);
this.course - object of the Firebase Observable object. The problem is that this part will not work: (click) = "openDeckOnBrowser (course.deckUrl). Since the .deckUrl course is empty, I cannot pass the value of the function.
Tho is the only hacker way I've found work so far:
<button id="{{(course | async)?.deckUrl}}" ion-button dark full large (click)="openDeckOnBrowser($event)"> <ion-icon name='cloud-download'></ion-icon> <div id="{{(course | async)?.deckUrl}}">View Deck</div> </button>
And on the click event:
openDeckOnBrowser(event):void { console.log(event); let target = event.target || event.srcElement || event.currentTarget; let idAttr = target.attributes.id; let url = idAttr.nodeValue; console.log (url); }
But is there any official and easier way to approach this?
source share