.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:
but not
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
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'
}
}
})
A trailing slash should not be added for URLs that end in a file name, such as .html, .php, .aspx, .txt, .pdf or .jpg. If you force a trailing slash on a file name, then that will cause the browser to think it is a folder and will result in a 404 error message.
Google sees the two as equivalent. But trailing slashes do matter for everything else because Google sees the two versions (one with a trailing slash and one without) as being different URLs. Conventionally, a trailing slash (/) at the end of a URL meant that the URL was a folder or directory.
The trailing slash matters for most URLs Conventionally, a trailing slash (/) at the end of a URL meant that the URL was a folder or directory. At the same time, a URL without a trailing slash at the end used to mean that the URL was a file. However, this isn’t how many websites are structured today.
There is certainly no SEO benefit to switching. On the other hand, if you are starting a new site today, then it is probably better to include a trailing slash simply because this is more common and more likely to be expected by users. Whichever one you choose, it makes sense to be ultra-consistent and have 301 redirects from one to the other.
You can use squash parameter to allow without trailing slash
params: {
location_id: {
value: null,
squash: true
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With