Comments (9)
Can you not simply do transition: Transition
without the @Inject. I didn't think that was necessary
from angular-hybrid.
As I mentioned in the original description, I did try variations like that.
It fails in the same way when the component is downgraded and used via string based routing.
angular.js:14525 NullInjectorError: R3InjectorError(RootModule)[Transition -> Transition -> Transition]:
NullInjectorError: No provider for Transition!
at NullInjector.get (core.mjs:6359:1)
at R3Injector.get (core.mjs:6786:1)
at R3Injector.get (core.mjs:6786:1)
at R3Injector.get (core.mjs:6786:1)
at ChainedInjector.get (core.mjs:13769:1)
at lookupTokenUsingModuleInjector (core.mjs:3293:1)
at getOrCreateInjectable (core.mjs:3338:1)
at ɵɵdirectiveInject (core.mjs:10871:1)
at NodeInjectorFactory.Ng2Component_Factory [as factory] (ɵfac.js? [sm]:1:1)
at getNodeInjectable (core.mjs:3523:1) '<ng2-component class="ng-scope" ng-version="14.2.5">'
I read the source code, but i couldn't quite figure out which part of hybrid / ui-router / core is supposed to provide the $transition$
/ transition: Transition
object to be injectable.
from angular-hybrid.
I'm a little bit confused because Transition refers to the current transition in progress. When the component is loaded the transition is finsihed so it shouldn't exsist. What are you trying to use Transition for?
from angular-hybrid.
Is the transition finished by the time the component constructor is called?
The documentation at https://ui-router.github.io/ng1/docs/latest/modules/injectables.html#_stateparams
states that when $stateParams is injected into view controllers, it is the current per-transition object, not a finished / successful transition.
Quote
When injected into transition hooks, resolves, or view controllers, the object is the Per-Transition Object with the parameter values for the running Transition.
And the deprecation replacement code suggests injecting it like that into a view controller.
And by extension, I hoped the same would work for downgraded ng2 components.
What are you trying to use Transition for?
I'd like to get the transition to get the params() associated with it, because i was under the impression it is not the finished transition, and thus i should get the params from the transition, rather than say UIRouterGlobals.params
When the component is loaded the transition is finsihed so it shouldn't exsist.
Well it certainly exists and is injected when not using the string-based routing.
from angular-hybrid.
I don't see any issue with you using StateService.params
(or UIRouterGlobals.params
) .... Also from checking the (angular code) the component gets instantiated when the transition is successful, so you shouldn't have to access or rely on Transition.
In relation to the link you send, there was some problems in AngularJS with relying on $stateParams thats why it's encouraged to move away from it. But you shouldn't have any issues with StateService.params o UIRouterGlobals.params when used inside a uiview Component
from angular-hybrid.
I see.
But then at what point is the ongoing transition object available? Only in resolve functions and transition hooks?
from angular-hybrid.
I see.
But then at what point is the ongoing transition object available? Only in resolve functions and transition hooks?
Exactly :). Only when a transition is in progress you should look at the transition object
from angular-hybrid.
Ok, thank you for your help!
I'm still curious why the $transition$
object is conditionally available in the constructor depending on the component type, but it's not that critical anymore.
from angular-hybrid.
Ok, thank you for your help!
I'm still curious why the
$transition$
object is conditionally available in the constructor depending on the component type, but it's not that critical anymore.
No worries, I'm trying to get the example repo running to see If I can have a look but as I said I wouldn't rely on the Transition object being available inside a component constructor.
Take into account that a Transition object only makes sense during a state change/transition and once the Transition is completed it becomes obsolete and any changes to the state would incur in a new Transition object being created.
from angular-hybrid.
Related Issues (20)
- Angular 10 Compatibility HOT 2
- Jest test suite failed to run AngularJS v1.x is not loaded! after upgrade from angular 7 to 9 HOT 6
- How to augment all routes with additional resolve using decorator HOT 2
- ui.router.upgrade' is not available! HOT 1
- Angular 9 - optimization: true breaks build HOT 1
- Version 12 causes "Unknown provider" on Angular states HOT 12
- Upgraded AngularJS component renders itself in ui-view HOT 1
- The target entry-point "@uirouter/angular-hybrid" has missing dependencies HOT 2
- Support for angular12 HOT 5
- UIViewNgUpgrade downgradedModule not specified HOT 1
- ngcc fails
- Angular 14 compatibility HOT 6
- Error bootstrapping AppModule Error: Cannot read properties of undefined (reading 'when') HOT 1
- Angular 15 compatibility HOT 3
- After update to 15: UI router error TypeError: this.factory is undefined HOT 19
- random error: Cannot find module '@uirouter/angularjs' or its corresponding type declarations. HOT 3
- Add support for v16 in @uirouter/angular-hybrid HOT 3
- After update to v15.0.2 I get this error "Cannot read properties of undefined (reading 'inherit')"
- Wrong NATIVE_INJECTOR_TOKEN import HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-hybrid.