无法使用 URL 导航至 ui-路由器状态

Can't navigate to ui-router state with URL

我正在使用 ui-router 开发一个简单的 angular 应用程序。我有几个状态用于 selecting,然后编辑有关发布者的信息。相关配置:

            .state('select-publisher', {
                url: '/select-publisher',
                templateUrl: '/Content/superadmin/src/templates/publishers/publishers.html'
            })

            .state('publisher', {
                abstract: true,
                url: 'publisher/{id:int}',
                templateUrl: '/Content/superadmin/src/templates/publishers/publisher.html'
            })
            .state('publisher.details', {
                url: '/details',
                templateUrl: '/Content/superadmin/src/templates/publishers/details.html'
            })
            .state('publisher.ad-tags', {
                url: '/ad-tags',
                templateUrl: '/Content/superadmin/src/templates/publishers/ad-tags.html'
            })
            .state('publisher.native-ads', {
                url: '/native-ads',
                templateUrl: '/Content/superadmin/src/templates/publishers/native-ads.html'
            })

在 select-publisher 状态中,我有一个很大的可用发布者列表。它们中的每一个都绑定到一个 ng-click 事件,该事件在我的控制器中触发以下功能:

 $scope.selectPublisher = function(publisher) {
     publisherService.setSelectedPublisher(publisher);
     $state.go('publisher.details', {id: publisher.Id});
 };

这工作得很好,将我带到 publisher.details 状态并呈现正确的视图。此时,我浏览器中的 URL 指向 localhost:1337/superadmin#/publisher/39/details,其中 39 是我 select 编辑的发布者的 ID。

问题是,如果我刷新此页面或尝试通过将 URL 从应用程序的另一个区域粘贴到浏览器中来直接导航到该页面,我总是被带回 select-publisher 状态。我希望能够配置我的状态,以便我能够基于 URL.

导航到详细信息状态(或任何其他状态)

值得注意的是,我确实在我的所有状态之后定义了一个 catch all 路由:

$urlRouterProvider.otherwise('/select-publisher');

我假设由于某种原因它被触发了,但我无法解释为什么导航在我的应用程序中可以使用 $state.go 正如我在我的控制器中指出的那样以及使用 ui-sref directive 在我的 HTML 模板中,但不是通过直接导航到 URL.

可能是因为缺少斜杠 url: /publisher/{id:int}