How to send image to a view using $stateParam. P.S. image contains '/'


#1

I am having trouble to send data from one view to another using $stateParam. as it contains “/” and it is interpreting “/” as a route. totally stuck Please help.

State-configuration:
state('app.donationstatus', { url: '/donationstatus/:data', views: { 'menuContent': { templateUrl:'app/donationstatus/view/donationstatus.html', controller:'donationStatusController' } } })

view
<a href="#/app/requestdetail/{{data}}">

my model

$scope,data="image/myimg.png"//or a base 64 image

findings

  • ‘/’ in the data is misinterpreted.
  • It looks for the url : /app/requestdetail/image/ insteat of /app/requestdetail/.

#2

add params field to your state

state(‘app.donationstatus’, {
url: '/donationstatus’
params: { image: ‘’},
views: {
‘menuContent’: {
templateUrl:‘app/donationstatus/view/donationstatus.html’,
controller:‘donationStatusController’
}
}
})

and then then get the value using $stateParams.image