Timeline for angular object oriented services and es6
Current License: CC BY-SA 3.0
17 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 22, 2015 at 20:52 | answer | added | Bergi | timeline score: 1 | |
| Oct 22, 2015 at 20:23 | comment | added | hiroprotagonist | @PSL " How you are defining the class looks fine, your issue may be how you are using it" -- yea this is helpful, I should look more into this, thanks! | |
| Oct 22, 2015 at 20:17 | comment | added | hiroprotagonist | If I simply injected MyService I would just have one instance of MyService, not something that can make instances of objects. Basically I am trying to implement blog.revolunet.com/blog/2014/02/14/… in es6. | |
| Oct 22, 2015 at 19:32 | comment | added | PSL |
@hiroprotagonist Why dont you just inject MyService? Also you need to show us the source of error, i.e how you are invoking the service method, this is determined by how it is invoked not how it is defined.
|
|
| Oct 22, 2015 at 19:30 | history | edited | hiroprotagonist | CC BY-SA 3.0 |
added 475 characters in body
|
| Oct 22, 2015 at 19:28 | comment | added | hiroprotagonist | yea it is being registered, and injected, etc. i left that out but I can put it in | |
| Oct 22, 2015 at 19:28 | comment | added | JB Nizet | Yes, I realized it and udated my comment. If you want help, post the code reproducing the problem. It's likely not being caused by the way the service is defined, but by the way someFunction is called. | |
| Oct 22, 2015 at 19:27 | comment | added | hiroprotagonist | In the es6 case that is what is happening. MyServiceMaker is making MyService. | |
| Oct 22, 2015 at 19:26 | comment | added | JB Nizet | Why should the service create instances of its own class, rather than instances of another class. It would make things much less confusing, and you wouldn't lose anything. That's what you're doing in your second example, and it should work fine. If it causes a problem, then post the real code and explain what the problem is. | |
| Oct 22, 2015 at 19:24 | history | edited | hiroprotagonist | CC BY-SA 3.0 |
added 294 characters in body
|
| Oct 22, 2015 at 19:24 | comment | added | PSL |
You could just register via angular service and inject it right? You may want to read about what this means. How you are defining the class looks fine, your issue may be how you are using it.
|
|
| Oct 22, 2015 at 19:24 | comment | added | hally9k | What about factories?? | |
| Oct 22, 2015 at 19:24 | answer | added | agconti | timeline score: 0 | |
| Oct 22, 2015 at 19:23 | comment | added | hiroprotagonist |
ah sorry i added that part of the code. also, agree, definately pretty terrible that I am instantiating this myself ... although, not sure how else to do it? Even in the es5 version I was instantiating it myself (just using the new syntax instead of my own stupid maker class)
|
|
| Oct 22, 2015 at 19:23 | comment | added | PSL | Can you show more code on which line throws error? I am assuming it is someFunc how are you invoking someFunc? You cannot copy the reference of myService.someFunc and call it from the view. | |
| Oct 22, 2015 at 19:20 | history | edited | hiroprotagonist | CC BY-SA 3.0 |
added 290 characters in body; added 2 characters in body
|
| Oct 22, 2015 at 19:12 | history | asked | hiroprotagonist | CC BY-SA 3.0 |