Here's my state definition:
.state('root.countryreport', {
url: '/report/:country',
params: {
data: null
},
views: {
'container@': {
templateUrl: '/templates/country_dashboard.html',
controller: 'countryReportController'
}
}
})
And here's my a href:
<a ui-sref="root.countryreport({data: {id: item.id}, country: lowercase(item.title)})">
{{ item.title }}
</a>
The data parameter is passed as null no matter what I do. What am I doing wrong? The country parameter is passed as expected.
I am using angular-ui-router: 0.2.18
Because you defaulted its value to null
, so in current case even if you pass value to data
it will always set to null
You need to make default value as null
when nothing has passed to it by having {value: 'defaultvalue'}
expression.
Code
params: {
data: {
value: null
}
},