Access 'this.?' is 'undefined'


#1

help me please!!!
access ‘this.??’ is always ‘undefined’, I can’t assign ‘this’ any value in ionic 3.20.0 for android


#2

This is an exceptionally vague problem. What is this.??
If that’s a variable, it’s pretty poorly named. Question Mark’s are not ideal variable names,

Perhaps you could post the actual code that you’re referencing?


#3

@sltruman plz share some piece of code.


#4

@jaydz @ajaysaini
oh, I just access member function via ‘this’ but it is undefined.
it worked fine before,not only map of object even any variable.


#5

where is your call to “atToSelf” function?


#6

@sltruman, when you are calling atToSelf() function . this function is called before initialising this.map variable


#7

where do you see the calling for atToSelf() ?


#8

@avishai_peretz_dev @ajaysaini
I called function atToSelf() in a button of page of html. that button called successed after called ionViewDidLoad().
the issue is that map is undefined but i have assign this.map in ionViewDidLoad()


#9

need to see code!
Please advise


#10

@sltruman
which plugin you are using ?
and where you initialised coords ?
plz share link
try this one https://ionicframework.com/docs/native/google-maps/


#11

@ajaysaini @avishai_peretz_dev
yeah, i am going to home.
i will share the code.
i consider it unrelated with type of map becase it is not only map even any variable.


#13

@ajaysaini @avishai_peretz_dev
I solved it becase ionic not support directly binding ‘this.fun()’ via jquery.
like following:
$(’.atToSelf’)[0].onclick = () => { this.atToSelf() } // ok this.map is object
$(’.atToSelf’)[0].onclick = this.atToSelf // error this.map is undefiend

thanks


#14

You can use it with bind also

$(’.atToSelf’)[0].onclick = this.atToSelf.bind(this);

But what is the reason to use jQuery in ionic 3 project?


#15

jQuery is my favorite and ionic3 lacks some feature of operation of DOM so I use just jQuery.