Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Provide mechanism to specify controller/template mapping in the place routes are defined. #154

@hannahhoward

Description

@hannahhoward

Hi, I've been looking over the code for the new router, coming from a ui-router background. I can see the use of conventions for mapping components to templates and controllers, but it also feels very limiting not to be able to configure these. I've now located the $componentLoaderProvider service, but specifying these mappings in a single global function far away from the place you map components to routes feels cumbersome, and may lead to a lot of confusion when the mappings are not obvious to someone looking at the router configuration code. I'd like to implement an alternate interface that allows you do do something like this:

$router.config([
{path: '/', component: 'componentName', controller: 'SomethingController', template: 'SomeTemplate' }
]);

or alternatively:

$router.config([
{path: '/', component: { controller: 'SomethingController', template: 'SomeTemplate' }
]);

Among other things, this would make ui-router transitions much easier. Happy to implement it myself but I'd prefer to know it's something the team is open to first before I put in the effort.

One other suggestion you don't want to pollute the $router interface: provide an alternative service like '$componentMapper' that has an interface like:

$componentMapper.map({
'componentName': { controller: 'SomethingController', template: 'SomeTemplate' }
})
(could be called multiple times in separate places so that component mappings stayed near router configuration)
Admittedly I think this could be implemented as an addon atop the existing $componentLoader functionality.

Not sure if this is a duplicate of #99

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions