Skip to content

Any chance this could be extended for filters and services? #7

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

Open
PerfectedApp opened this issue Mar 27, 2013 · 7 comments
Open

Any chance this could be extended for filters and services? #7

PerfectedApp opened this issue Mar 27, 2013 · 7 comments

Comments

@PerfectedApp
Copy link

Your solution so far is wonderful for us. Thanks for making it open!

@PerfectedApp
Copy link
Author

Probably not the cleanest approach, but I just created lazy-filters and services much like what was done with directives.

@sgentile
Copy link

I'd like to see what you have done - would you consider forking this and adding it to show ? (or a pull request maybe ?)

@matys84pl
Copy link
Owner

To add something to the discussion... the other day I was thinking about something like this:

routeProvider.when('/view2', routeConfig.config({
   controller: "controllers/myController",
   filters: ["filters/filter1", "filters/filter1"]
   services: [...]
   directives: [...]
}))

so you could basically define whatever you want for your view. This could be even done via json file as an external configuration.

The other idea... what if your controller could define the dependencies using require plugins, like:

define("controller", [
    "service!./myService",
    "directive!./myDirective"
], function () {
   // the one thing that I don't like about the idea is that it
   // mixes view and controller dependencies...
})

... just thinking out loud ;)

@sgentile
Copy link

I like the second concept - as it seems a bit off to me that a 'router' is what wires up all the dependencies - whereas if a controller is using a service, then what you have feels right to me.

I don't mind the view/controller - as I tend to always associate a controller to a view (perhaps I have a more MVVM perspective)

@PerfectedApp
Copy link
Author

Made a pull request. Hope it works for you guys. There's still work here to be done...

@gnrlwart
Copy link

@matys84pl, I've actually been using something similar to your first idea, with the routes being defined in an array, then passed into a router module all together for it to handle registering them.

It seemed nice at first, but as we've built up a larger number of more complex routes, having all of the dependencies defined in two separate files (the route config and controller module) has proven cumbersome.

You're second idea is intriguing though, and I think the problem of having dependencies defined in two such desperate places outweighs defining the view and controller dependencies together. We could still separate them with comments. :)

@kevinwolfcr
Copy link

Just reliving this issue, i would feel more comfortable with the second approach:

define("controller", [
    "service!./myService",
    "directive!./myDirective"
], function () {
   // the one thing that I don't like about the idea is that it
   // mixes view and controller dependencies...
})

Because it would make me able to strictly specify my controller dependencies, my only thought about is that the directives should go on the app.js dependencies, to make them able across all the application.

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

5 participants