arturpasnik
779
2
Vue

vue js anonymous function access this.user

Posted 2 years ago by arturpasnik

after getting response from geocoder how to access this.properties ?

checkPostcode(postcode){
                var lat = null;
                var lng = null;
                var geocoder= new google.maps.Geocoder();
                geocoder.geocode( { address: postcode}, function(results, status){

        console.log(this.user);    // undefined 

                    if (status == google.maps.GeocoderStatus.OK) {
                        lat = results[0].geometry.location.lat();
                        lng = results[0].geometry.location.lng();
                        console.log(lat);
                        console.log(lng);
                    } else {
                        this.errors.errors.unshift({
                            field: 'postcode',
                            msg: 'Invalid postcode.',
                            scope: '__global__'
                        });
                    }
                });

Please sign in or create an account to participate in this conversation.