angular / router

The Angular 1 Component Router
MIT License
665 stars 135 forks source link

HTML5LocationStrategy fails to update path on router.navigate #366

Closed bryantharpe closed 8 years ago

bryantharpe commented 8 years ago

It appears that only the HashLocationStrategy updates the url on calls to router.navigate. When I change my LocationStrategy to the HTML5LocationStrategy the urls no longer update when navigating from "/products/:productId" -> "/". The navigation does occur, though.

This is happening on Alpha.31.

The code I'm using is below.

Component Controller code

    updateProduct(product: {productId:string, name:string, description:string}) {
        this.productStore.updateProduct(product);

        this.router.navigate('/');
    }

Routes

@RouteConfig([
    {path: '/', component: ProductsList, as: 'Products'},
    {path: '/products/:productId', component: UpdateProducts, as: 'UpdateProducts'}
])

Bootstrap

import { httpInjectables } from 'angular2/http';
import { bootstrap, bind } from 'angular2/angular2';
import { routerInjectables, LocationStrategy, HashLocationStrategy, HTML5LocationStrategy } from 'angular2/router';
import { Onboarding } from './components/onboarding/onboarding';

bootstrap(Onboarding, [
    httpInjectables,routerInjectables, bind(LocationStrategy).toClass(HTML5LocationStrategy )
]);