ui-router state resolve entries are being evaluate

2019-06-09 07:41发布

问题:

UI-Router resolve entries are reloading twice when using $state.go or ui-sref when using an optional {parameter}, and the optional parameter is not filled.

.state('dashboard.loan', {
    url: "/loan/:type/{instanceid}",
    templateUrl: '/app/dashboard/views/package.html',
    controller: 'PackageController',
    controllerAs: 'packageCtrl',
    resolve: {
        UserAuth: session
    }
})

// Resolves only once when both parameters are provided
$state.go( 'dashboard.loan',
           { packageType: packageType, 
             packageInstanceId: packageInstanceId } );


// Resolves twice when only one parameters is provided
$state.go( 'dashboard.loan',
           { packageType: packageType } );

I'm using ui-router v0.2.11. Any ideas, can't seem to find a solution.

Solution for v0.2.11 Don't use optional curly brace query parameter

回答1:

This was a bug in 0.2.11 and should be fixed in 0.2.12.

https://github.com/angular-ui/ui-router/issues/1396