@jaydz wrote:
Until recently, I was under the impression that using the 'this' keyword using ionic's product and its' Component/Page structure was not "bad". As an example, I have a page called TicketsPage. Im especially curious in two regards.
@Component ({
selector: 'page-tickets',
templateUrl: 'tickets-html',
}).export class TicketsPage {
venues: any;
users: any;constructor (public mySharedOb: MySharedOb) {
this.venues = [];
this.user = {};
this.user['tickets'] = [];
}getTickets(){
for (var i = 0; i < this.user['tickets'].length; i++) {
this.venues.push( this.user['tickets'][i] )
}}
My questions are:
Simply put, is this a bad practice? Is using 'this' and assigning it properties the same as using 'this' in a not-ionic environment?
Is my use of 'this' creating properties on and/or exposing the global environment?
Or am I creating properties on TicketsPage, my ionic page?
Being that TicketsPage is a 'class', is using 'this' in reference to it just fine?
Is creating this.venues as an array in TicketsPage's constructor any better/worst/different than creating this.user as an object in TicketsPage's constructor and assigning this.user new properties?
Sorry to post a pretty basic Javascript question here, but from what I understood, using classes and using them in Ionic's context had different implications. Am I wrong?
Posts: 1
Participants: 1