Comments (14)
Great idea! I'm facing the same problem on my project. However I gave your Idea a try.
See my commit: Resolve Decorator
But I got stuck. The AoT compiler prints the annoying error:
ERROR in Error encountered resolving symbol values statically. Calling function 'makePropDecorator', function calls are not supported.
I don't know how to get rid of this. I tried to export and wrap the function call, without any success.
@aitboudad I'd appreciate if you could have a look on it.
from angular.
It should be solved soon see angular/angular@bd64ab5
from angular.
from angular.
I really want to use @Input()
because it allows components to be agnostic towards being routed or not routed.
from angular.
another approach is to pass the inputs through state config:
{
name: 'app',
component: App,
resolve: [
{
- token: 'app',
+ input: 'app',
deps: ...
},
],
},
from angular.
another approach is to pass the inputs through state config:
That would not allow resolves declared on a parent state to be bound to a (routed) child component. It would have to be mapped on the view level. We already have the bindings:
property on a view declaration which serves this purpose. However, making it mandatory would introduce a lot of boilerplate.
{
name: 'app',
component: App,
+ bindings: { app: 'app' },
resolve: [
{
token: 'app',
deps: ...
},
],
},
from angular.
AOT
already introduced a lot of boilerplate :) so I'm ok with the bindings:
property as I think the bundle size is important too (in my case removing decorators shrunk the bundle size by ~170 Kb)
from angular.
I'd like to point out that in 1.0.0-beta.4
the only workaround is to inject the resolves into the component constructor:
@Component({
})
export class MyComponent {
constructor(@Inject('myResolve') public resolveData: any) {
}
}
- or -
@Component({
})
export class MyComponent2 {
public myResolve: any;
constructor(transition: Transition) {
this.myResolve = transition.injector().get('myResolve');
}
}
from angular.
since bindings
is implemented what do you think about adding a new option autoBindings
through the config part which will pass all resolved values into the component if the property have the same name of resolved value.
UIRouterModule.forRoot({ autoBindings: true })
from angular.
I've been considering a similar thing, but how can you tell if a newly constructed component has a property or not?
class FooComponent {
someInput: string;
}
from angular.
it seems not possible :(
from angular.
@aitboudad For now I'm going to use your original idea of a Decorator like @ResolveData() resolveInput
I don't like not using @Input()
, but this seems like a simple way to manage until Angular comes up with a solution for exposing metadata to for third parties, when we will remove @ResolveData
and have users switch back to @Input()
from angular.
@aitboudad that's very promising!
from angular.
I am going to remove the ResolveData
decorator before releasing beta.5
which will support angular 2.x I will then release beta.6
using the inputs as exposed in that commit.
from angular.
Related Issues (20)
- Support Angular 11 HOT 1
- Angular 12 HOT 8
- Future of ui-router? HOT 6
- Error: State 'quizzes' is already defined HOT 2
- uiSref doesn't work unless matching "name". Can't use full path/name. HOT 2
- How to lazy load with chunks HOT 11
- Incompatibility with Angular v13 - removal of `NgModuleFactoryLoader` HOT 1
- Angular 13 Support (libs update) and version policy HOT 13
- [Discussion] Monorepo requirements for ui-router packages HOT 11
- Redirects on local anchor reference HOT 2
- onError not redirecting HOT 1
- Angular v14 support HOT 2
- [bug(?)]: future state declaration's data not passed/merged to/with loaded child state HOT 1
- Angular 15 support HOT 5
- MergeInjector breaks normal Angular DI priority HOT 3
- [question] Lazy loaded module empty after creating
- Breaks when building with Angular 16
- Angular 16 support HOT 9
- Angular 17 support HOT 4
- Incorrect Ui Routing on iOS 17 safari private browsing mode.
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.