javascript - $state.go not working in Ionic -
i using $state.go inside controller of abstract state , not working. using $ionicpopup , on click of button want navigate state. shows no errors in console. here code.
.config(function($stateprovider, $urlrouterprovider) { $stateprovider .state('app', { url: '/app', abstract: true, templateurl: 'templates/menu.html', controller: 'appctrl' }) .state('app.contacts', { url: '/contacts', views: { 'menucontent': { templateurl: 'templates/contacts.html', controller: 'contactsctrl' } } }) .state('app.browse', { url: '/browse', views: { 'menucontent': { templateurl: 'templates/browse.html', controller: 'browsectrl' } } }) .state('app.signup', { url: '/signup', views: { 'signup': { templateurl: 'templates/signup.html', controller: 'signupctrl' } } }) .state('app.playlists', { url: '/playlists', views: { 'menucontent': { templateurl: 'templates/playlists.html', controller: 'playlistsctrl' } } }) .state('app.single', { url: '/playlists/:playlistid', views: { 'menucontent': { templateurl: 'templates/playlist.html', controller: 'playlistctrl' } } }); // if none of above states matched, use fallback $urlrouterprovider.otherwise('/app/browse'); }); and here javascript code appctrl
$scope.showcartpopup = function(){ $scope.cartitems = $localstorage.cart; $scope.costsum = 0; $scope.cartitems.foreach(function(element, index){ $scope.costsum += number(element.price); }); $scope.costsum = $scope.costsum.tofixed(2); console.log($scope.cartitems); var templatestring = "a long template string here"; $ionicpopup.show({ title: 'your cart items', template: templatestring, scope : $scope, buttons: [{ text: 'continue' },{ text: 'checkout', type: 'button-assertive', ontap: function(e){ $timeout(function() { $state.go("app.signup") }); //return $q.reject("rejection message!"); } }] }).then(function(res){ if(res == 'signup'){ console.log(res); $timeout(function() { $state.go("app.signup") }); } }); i used $timeout when $state.go not working @ didn't help. highly appreciated. in advance.
Comments
Post a Comment