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

allow to set extra data on route, can be accessed in controller #32

Closed
wants to merge 1 commit into from
Closed

Conversation

yasinuslu
Copy link
Contributor

I just needed this feature and couldn't find it. I thought it might be helpful.

@cmather
Copy link
Contributor

cmather commented Aug 13, 2013

Hey @yasinuslu, All of the options are passed along from the route definition. So you should be able to get to custom options inside the options of the route. If you tell me a little more about what you're trying to do I can see what exists already that might help. There's also first class support for a data function on routes and controllers. This gets called automatically (in an autorun) inside the run method of controller during rendering.

@yasinuslu
Copy link
Contributor Author

this.route('home', {
  path: '/',
  controller: 'ProductsController',

  action: 'list',

  foo: "different route same action, custom title ..."
});

ApplicationController = RouteController.extend({
  initialize: function() {
    // can't access to {foo:""}
  }
})


ProductsController = ApplicationController.extend({
  list: function () {
     // can't access to {foo:""}
  },
});

I couldn't find foo in any of those contexts. this, this.route, this.context, then i realized only a few selected keys were being assigned to newly created Route object.

If you help me access those variables i'd appreciate it.

@cmather
Copy link
Contributor

cmather commented Aug 13, 2013

foo should be available inside this.options in the controller. But I made some changes a few days ago to the way options are passed along and may have broken this. I will take a look this afternoon. The options from the router config should be passed along to the controller at constructor time.

@yasinuslu
Copy link
Contributor Author

Ah i was missing that i could access those fields from this.route.options, that's enough for me.

Thanks.

@cmather
Copy link
Contributor

cmather commented Aug 13, 2013

Yeah, still a little janky though. I'll be thinking how to clean this up. Thanks for bringing up the issue.

@yasinuslu yasinuslu closed this Aug 13, 2013
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

Successfully merging this pull request may close these issues.

None yet

2 participants