toddmotto / angular-component

Fully featured .component() polyfill for Angular v1.3+
https://toddmotto.com
Other
191 stars 29 forks source link

Angular ui-router resolved object are undefined when trying to access from within components #40

Closed asadsahi closed 7 years ago

asadsahi commented 7 years ago

@toddmotto I am having this problem trying to use resolved objects from ui-router inside component, but these object are undefined when trying to access from components.

In angular 1.5 with ui router, we can place resolved data like this:

<my-component data="$resolve.MyData"..... and resolve object looks something like this:

 resolve: {
                        MyData: ['myservice', function (myservice) {
                            return myservice.getDataAsync()
                        }],       

We have been working with angular 1.5, but now have to roll back to 1.3 for some issues and for components we are using your polyfill. Good job :+1:

After adding polyfill, I have tried both approaches:

1) bindings

 bindings: {
                data: '<MyData' // Doesn't work
                 //data: '<' // This doesn't work either
            }

2) Injecting into controller of component:

MyController.$inject = ['data']; function MyController(data) {

But data object received from route resolve is always undefined.

It will be really helpful if an example with router can be created. Thanks

asadsahi commented 7 years ago

got it working finally

asadsahi commented 7 years ago

working example: http://jsbin.com/xoqixemaro/1/edit?html,js,output