Show different page through conditional sentence


#1

Hello!

I created a app with CORS auth and after login, I’m check that user type are logged in app. Then, I use $state.go, to define the first page that user see. Basically I have a two differents page. One for user type A and One for user type B, but actually, when I set the $state.go for a page and do logout and do login, again, even the user type be different the page remains the same. But if I do the logout for twice, it’s works. Looks like the pages are cached, but I’m using “cache: false” and “ionicViewService.clearHistory()”.

The code of $state.go, is like this:

$scope.login = function() {
          $http({
              method: 'POST',
              url: 'MyUrl',
              headers: {'Content-Type': 'application/x-www-form-urlencoded'},
              transformRequest: function(obj) {
                  var str = [];
                  for(var p in obj)
                  str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
                  return str.join("&");
              },
              data: {Username: $scope.data.username, Password: $scope.data.password}
          }).success(function (data, status, headers, config) {
              //$state.go('app.about');
              $scope.getRole();
              if ($scope.data.role==='usertypeA') {
                $state.transitionTo('app.pageA');  
              } 
              if ($scope.data.role==='usertypeB') {
                $state.transitionTo('app.pageB');
              }

...

Thanks!