michaelbromley / michaelbromley/angular-es6

Are you sure the factory works correctly?

Open
#12 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
364
Forks
59
PR merge metrics
No merged PRs in 30d

Description

``` js
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`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the ThingFactory example in the issue and inspect how AngularJS registers and invokes the factory, especially the newThing() call and its this binding. Reproduce the reported window binding, then verify that the factory method retains the expected object context and add or update a regression test if the repository provides a relevant test location.

Written by the indexing model from the issue text.

Assessment

Tech stack
angularjs, javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.