5
.state('tabs.map', {
    url:'/map/{location_id}',
    params: {
      location_id: { value: -1 }
    },
    views: {
      'map-tab':{
        templateUrl:'templates/map.html',
        controller:'MapCtrl'
      }
    }
  })

I've tried a number of different options for optional params that I've found on the web but none of them work exactly like I'm looking for. The code I've added allows for:

  • /tab/map/.*?

  • /tab/map/

but not

  • /tab/map

I'm not sure why the trailing slash is causing a problem because from what I've read it shouldn't be a problem. Does anyone know how to resolve this?

Recently Consulted

Solution

Introduction of squash to param variable

.state('tabs.map', {
    url:'/map/:location_id',
    params: {
      location_id: { value:null, squash:true }
    },
    views: {
      'map-tab':{
        templateUrl:'templates/map.html',
        controller:'MapCtrl'
      }
    }
  })
Community
  • 1
  • 1
Jacksonkr
  • 31,583
  • 39
  • 180
  • 284

1 Answers1

7

You can use squash parameter to allow without trailing slash

  params: {
      location_id: {
        value: null,
        squash: true
      }
   }
kwangsa
  • 1,701
  • 12
  • 16