I'm using Angular 1.6 and ui-router 1.0.0-rc.1. I set up a couple of simple states:
.config(function($stateProvider) {
$stateProvider.state({
name: "foo",
url: "/foo",
template: "<foo-widget layout='row'/>"
});
$stateProvider.state({
name: "bar",
url: "/bar",
template: "<bar-widget layout='row'/>"
});
$stateProvider.state({
name: "home",
url: "",
template: "<foo-widget layout='row'/>"
});
Then on the main page I put an mdNavBar:
<md-nav-bar nav-bar-aria-label="navigation links" md-selected-nav-item="foo">
<md-nav-item name="foo" md-nav-sref="foo">Foo</md-nav-item>
<md-nav-item name="bar" md-nav-sref="bar">Bar</md-nav-item>
</md-nav-bar>
When I click on "Foo" it takes me to http://example.com/example/#!/foo
, and when I click on "Bar" it takes me to http://example.com/example/#!/bar
.
But when I manually enter the URL http://example.com/example/#!/foo
, the Foo nav-item is not selected, even if it was already selected. Also if I enter the URL http://example.com/example/#!/bar
, the Bar nav-item is not selected, even though the state apparently changes to "bar" (based upon my embedded components.
Why isn't the mdNavBar following the current ui-router state?