app state with optional param and no trailing slash

angularjs, ionic-framework

Solution

You can use squash parameter to allow without trailing slash

  params: {
      location_id: {
        value: null,
        squash: true
      }
   }

Problem

``` .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 - Angular UI-Router: Multiple URLs to single state - AngularJs UI router - one state with multiple URLs - Can angularjs routes have optional parameter values? - Laravel 4 Route issues with multiple and optional get params 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' } } }) ```

Original source

Related problems