Navigation

Thursday 20 April 2017

AngularJS: Passing Parameters without Showing Them in State URLs

If you don't want to appear parameters in the url. You need to add a new field in the state, i.e "params" and create links as shown in below code.
For example.
.state('SignInOut', {
        url: '/SignInOut',
        params: {
            Id: null,
            SId: null
        },
        views: {
            '': {
                templateUrl: 'templates/SignInDetails.html',
                controller: 'SignInDetailsCtrl'
            }
        }
    })  

The link you create is
<a ui-sref="SignInOut({Id:{{sub.ProjectId}},SId:{{sub.SubProjectId}}})"> SignIn Report</a>

Or can you pass them to $state.go() too.
$state.go('SignInOut', { Id: ProjectId, SId: SubProjectId });




No comments:

Post a Comment