Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are you sure the factory works correctly? #12

Open
moltar opened this issue Jun 11, 2016 · 1 comment
Open

Are you sure the factory works correctly? #12

moltar opened this issue Jun 11, 2016 · 1 comment

Comments

@moltar
Copy link

moltar commented Jun 11, 2016

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
Copy link
Author

moltar commented Jun 11, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant