$state.go() not working. ? Why.?


#1

Hello. I can not make the page redirect. I did not quite solve the problem. Could you help. Where am I making mistakes. ?

.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'
      }
    }
  });
.controller('PlaylistsCtrl', function($scope) {
  $scope.playlists = [
    { title: 'Reggae', id: 1 },
    { title: 'Chill', id: 2 },
    { title: 'Dubstep', id: 3 },
    { title: 'Indie', id: 4 },
    { title: 'Rap', id: 5 },
    { title: 'Cowbell', id: 6 }
  ];
})

.controller('PlaylistCtrl', function($scope, $stateParams,$state) {

      $scope.id = $stateParams.playlistId;

      switch ($scope.id) {
         case 1:
          $state.go('app.italian_opening');

           break;
         case 2:
          $state.go('app.vienna_opening');
           break;
         default:

           break;
       }
});

#2

it should be $state.go(‘app.playlists’); where is your routing for ‘app.italian_opening’ ??


#3

I’m sorry. It’s is other code.

  .state('app.italian_opening', {
    url: '/italian_opening',
    views: {
      'menuContent': {
        templateUrl: 'templates/italian_opening.html',
        controller: 'italianCtrl'
      }
    }
  })

  .state('app.italian_opening_list', {
    url: '/italian_opening_list/:code/:number',
    views: {
      'menuContent': {
        templateUrl: 'templates/trapDetay.html',
        controller: 'italianTuzakCtrl'
      }
    }
  })


#4

try this one:


$location.path('/italian_opening');

#5

Not working. What can I do. ?


#6

Not working again. Simple code but not running.