angular-es6 icon indicating copy to clipboard operation
angular-es6 copied to clipboard

Are you sure the factory works correctly?

Open moltar opened this issue 9 years ago • 1 comments

class ThingFactory {

    /*@ngInject*/
    constructor($timeout) {
        this.$timeout = $timeout;
    }

    newThing() {
        console.log('Getting a new Thing...');
        return this.$timeout(() => new Thing(), 100);
    }
}

register('app').factory('thingFactory', ThingFactory);

In my app, newThing() doesn't have access to ThingFactory object's this. Rather this points to window.

moltar avatar Jun 11 '16 08:06 moltar

I think this is more specific to intercept handlers:

http://stackoverflow.com/questions/28638600/angularjs-http-interceptor-class-es6-loses-binding-to-this

^ This is the exact problem I'm experiencing. Maybe nothing to do with you register function.

moltar avatar Jun 11 '16 08:06 moltar