I have this function inside my class which has Destructuring parameters
export default class MainCtrl {
    constructor(mainService ) {
        'ngInject';
        this.mainService = mainService;
    }
    $onInit() {
        navigator.geolocation.getCurrentPosition(this.search);
    }
    search({ coords }) {
        console.log(this); // shows undefined
        this.mainService.search(coords);
    }
}
Now when im using this.mainService it says this is always undefined. How to pass the this instance on this kind of function?
 
    