Skip to content

Commit method prefix a slash when none is needed #5627

Closed

Description

@epotvin

In the case you have a root router config with a route with path "/...", linked to a component with his own child router config has in the following example :

@Component({
    selector: 'app'
})
@View({
    template: 'app.html',
    directives: [ROUTER_DIRECTIVES]
})
@RouteConfig([
    {path: '/...', as: 'SubApp', component: SubApp},
    {path: '/login', as: 'Login', component: Login},
])
class App {
}

@Component({
    selector: 'subapp'
})
@View({
    templateUrl: 'sub.html',
    directives: [ROUTER_DIRECTIVES]
})
@RouteConfig([
    {path: '', as: 'Home', component: Home},
    {path: '/whatever', as: 'Whatever', component: Whatever}
])
export class Trainer {
}

With this config, pointing your browser on "/" or simply "" points to the Home route. "/login" on Login, "/whatever" on Whatever. This structure allows to put some header in the sub.html file which doesn't appears when you access the login route.

It works very well, except the part where the commit method of the RootRouter class make the emitPath object to get prefixed with a / when it's not empty. But in that case, the empty path the SubApp root already add it every time, making it appearing twice when the state is pushed in the history. This consequently makes it fail.

I fixed it by extending the if statement with a verification of the said slash at the beginning of the path. I'm creating a pull request right away.

Activity

  1. changed the title [-]Commit method prefix a slash when none is need[/-] [+]Commit method prefix a slash when none is needed[/+] on Dec 5, 2015
  2. added 2 commits that reference this issue on Dec 5, 2015
  3. csquillen commented on Dec 19, 2015

    @csquillen

    +1

  4. vicb commented on Sep 24, 2016

    @vicb
    Contributor

    this is related to the old router

  5. angular-automatic-lock-bot commented on Sep 9, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  6. locked and limited conversation to collaborators on Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions