marklagendijk / ui-router.stateHelper

A helper module for AngularUI Router, which allows you to define your states as an object tree.
MIT License
235 stars 40 forks source link

Home page isn't loaded and $urlRouterProvider incorrectly fixes url to one value. #31

Closed davidzwa closed 9 months ago

davidzwa commented 6 years ago

I can't get any home page to load in my <ui-view></ui-view> element, unless I click my navigation bar to load a link. Then the route changes and the correct page is loaded. Combining with $urlRouterProvider.otherwise('page-name') the location hash doesn't change anymore.

So it is not possible for me to set a default page. Any idea what could be wrong?

Bower dependencies:

{
  "name": "board-client",
  "description": "A sample Angular application",
  "dependencies": {
    "angular": "^1.6.10",
    "angular-ui-router": "^1.0.15",
    "angular-ui-router.stateHelper": "^1.3.1",
    "angular-bootstrap": "^2.5.0",
    "angular-resource": "^1.5",
    "angular-animate": "^1.6.10",
    "bootstrap": "^4.1.0",
    "jquery": "^3.3.1",
    "font-awesome": "^5.0.10",
    "popper.js": "^1.14.3"
  }
}

Statehelper config:

    .config(["stateHelperProvider",
        function (stateHelperProvider) {
            stateHelperProvider
                .state({
                    /* Any pages that don't require authentication live here */
                    name: "public",
                    abstract: true,
                    children: [
                        {name: 'board', url: 'board', templateUrl: 'public/components/board/board.html'}
                    ]
                }, {keepOriginalNames: true})
                .state({
                    name: "private",
                    abstract: true,
                    data: {
                        requireLogin: true      // Require auth
                    },
                    children: [
                        {name: 'wells', url: 'wells', templateUrl: 'public/components/wells/wells.html'},
                        {name: 'settings', url: 'settings', templateUrl: 'public/components/settings/settings.html'},
                        {name: 'orders', url: 'orders', templateUrl: 'public/components/orders/orders.html'}
                    ]
                }, {keepOriginalNames: true});
        }])

Also note that I had to use keepOriginalNames set to true to avoid the 'route cannot contain dots'-error.