Timeline for Angular Injecting Multiple Dependencies Into Factory
Current License: CC BY-SA 3.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 5, 2016 at 14:33 | vote | accept | GavinBelson | ||
| Oct 4, 2016 at 23:13 | comment | added | Anil | Also, this issue your bring up is a separate issue entirely, you may need to post a separate question to resolve this issue if you need further guidance on it. | |
| Oct 4, 2016 at 23:10 | comment | added | Anil |
The infdig error that is thrown is the clue to the problem. Reference: infdig. I would bet that if you comment out the $route.refresh(); call that the error goes away, but it won't solve the issue. Since it sounds like you need to refresh the route upon successfully getting some information from the server, why not use an angular resolve for the route instead and get the information before going to that route? Reference: ui-router resolve
|
|
| Oct 4, 2016 at 20:59 | comment | added | GavinBelson | Yeah, I have and it works. But as soon as I add any second dependency to a factory, I get: Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations: [] | |
| Oct 4, 2016 at 20:41 | comment | added | Anil |
This is the correct way of injecting routes. You don't need to declare $route anywhere else. If your application is generating an error, or stops working once you add this, then there is probably some other configuration issue in your application. Have you properly added ui.router as a dependency for your module(s)?
|
|
| Oct 4, 2016 at 20:37 | comment | added | GavinBelson | Hmm.. that's what I started with.. didn't work. Do I need to declare the $route elsewhere outside of the factory? I am using ui.router for routing.. | |
| Oct 4, 2016 at 20:29 | history | answered | Anil | CC BY-SA 3.0 |