angularjs - Angular StateParams never changes when Url params change? -
i creating ionic app, , have basic routing scenario, trying go detail page id param, optional.
navigation occurs succesfully everytime, when try , access value in controller remains same whatever first time request was.
for e.g navigating playlists/1
output object {playlistid: "1"}
when navigating playlists/2
again output object {playlistid: "1"}
i have tried many things, can't find issue appreciated.
my route setup looks this:
.state('app.single', { url: '/playlists/:playlistid', views: { 'menucontent': { templateurl: 'templates/playlist.html', controller: 'playlistctrl', resolve: { playlistid: function($state, $stateparams) { return $stateparams.playlistid; // note changes every time. put here testing. } } } } })
and controller:
.controller('playlistctrl', function($scope, $stateparams) { console.log($stateparams);
navigating using:
<div class="card"> <div class="item item-text-wrap" ui-sref="app.single({playlistid: undefined})"> test </div> </div> <div class="card"> <div class="item item-text-wrap" ui-sref="app.single({playlistid: 1})"> test 1 </div> </div> <div class="card"> <div class="item item-text-wrap" ui-sref="app.single({playlistid: 2})"> test 2 </div> </div>
it sounds you're hitting cache. can disable adding cache:false
state:
.state('app.single', { cache: false, //add url: '/playlists/:playlistid', views: { 'menucontent': { templateurl: 'templates/playlist.html', controller: 'playlistctrl', resolve: { playlistid: function($state, $stateparams) { return $stateparams.playlistid; // note changes every time. put here testing. } } } } })
Comments
Post a Comment