Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The way to pass reference to event through the route config #110

Closed
michalpanek opened this issue Aug 3, 2016 · 3 comments
Closed

The way to pass reference to event through the route config #110

michalpanek opened this issue Aug 3, 2016 · 3 comments

Comments

@michalpanek
Copy link

michalpanek commented Aug 3, 2016

I have that situation:

Route config from statefull route component:

.state('conferences.conferencesList', {
        url: '/list',
        component: 'conferenceList',
        params: {
          conferencesList: undefined,
          onAddConference: undefined
        },
        resolve: {
          conferencesList: ($stateParams) => $stateParams.conferencesList,
          onAddConference: ($stateParams) => $stateParams.onAddConference
        }

and I have stateless component, which is children component for statefull component:

let conferenceListComponent = {
  bindings: {
    conferencesList: '<',
    onAddConference: '&'
  },
  template,
  controller
};

where onAddConference is a event to fire up to statefull parent component by stateless component (conferenceList in my example)
How Can I pass to bindings of stateless component "reference" to function from my statefull component ? How can I do this in route configuration ?

I tried send "reference" to function by

 $state.go('somestate', ({
someBindings: something,
someEvent: this.someFunction
}); 

but I got a error message:

TypeError: Cannot read property '1' of null(…)

Is there a way to solve this issue, or am I entirely wrong ?

@michalpanek
Copy link
Author

Thanks Todd for answered me in Disqus.

The js object must be passed through angular ui-router params with bindings inside, because of that js not really supporting passing variables by references, and when simple value, or function is passed by ui-router params, there is no possibility that bindings will be updated after changed in route component parent.

Please, correct me if I am wrong.

@toddmotto
Copy link
Owner

Hey @michalpanek did you fix this? Sorry slipped checking this one. If you're still having issues can you drop a jsfiddle of the code and reopen :)

@michalpanek
Copy link
Author

Yea, already I found the solution: angular-ui/ui-router#2888 (comment). but thanks:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants