Organizational Research By

Surprising Reserch Topic

angular ui router accessing stateparams on reload

angular ui router accessing stateparams on reload  using -'javascript,angularjs,angular-ui-router,parameter-passing,state'

In my Angular app, I have this route structure:

.state('mapping', {
    url: '/mapping',
    templateUrl: 'app/components/mapping/mapping.html',
    controller: 'MapCtrl as map',
    abstract: true,
    authenticate: true
.state('mapping.all', {
    url: '',
    templateUrl: 'app/components/mapping/partials/all.html',
    authenticate: true
.state('mapping.project', {
    url: '/:projectName',
    controller: 'ProjectCtrl as proj',
    templateUrl: 'app/components/mapping/partials/project.html',
    authenticate: true

The intended functionality is that when a user access 'mapping.project' the application will load all relevant information relative to that project using a projectID variable which is passed (invisibly) through $stateParams using ui-sref:

ui-sref="mapping.project({projectId:, projectName:})"

However this results in an unwanted behavior: when a user reloads the page when already on the 'mapping.project' state, nothing will be loaded because no $stateParams were effectively passed.

What would be the best way to get projectId on reload (and make sure my controller gets initiated again) without showing it on the URL?

asked Oct 11, 2015 by jekbishnoi
0 votes

Related Hot Questions

1 Answer

0 votes
answered Oct 11, 2015 by mtabakade