离子$ state.go首先进入以前的状态

时间:2016-11-20 14:08:33

标签: angularjs ionic-framework state

当我尝试使用$state.go('stateName')离子显示我之前的状态模板,然后进入预期状态时,我尝试使用$ionicHistory.clearHistory();离子显示另一个状态。我试图用$state.go('stateName')清除州的历史,然后转到州$scope.compareMySalary = function(){ Loading.showLoading(); var fieldsResult = checkForFields(); if (fieldsResult.fieldsFair) { var grade = GradeCalculator.calculateGrade($scope.userInfo.jobStuff.experienceToSubmit, $scope.userInfo.jobStuff.seniorityLevelToSubmit.class, $scope.userInfo.university.type); $scope.userInfo.jobStuff.gradeToSubmit = grade; UserInfo.addUserInfo($scope.userInfo.email, $scope.userInfo, function(){ }, function(error){ }); var itemToSubmit = $scope.userInfo.jobStuff.industrySegmentToSubmit.code +""+$scope.userInfo.jobStuff.subJobFamilyToSubmit.code+"" + $scope.userInfo.jobStuff.gradeToSubmit; if (fieldsResult.unclassified) { UserDataUnclassified.addUserData(itemToSubmit); }else{ UserData.addUserData(itemToSubmit); } ModelData.getModelData(itemToSubmit, function(salary){ var data = getParsedNumber(salary); data = parseFloat((data * $scope.userInfo.jobStuff.location.localCoefficient).toFixed(2)); generalGraphData.averageSalary = data; var userSalary = getYearlySalary($scope.userInfo.jobStuff.salaryToSubmit); generalGraphData.userSalary = userSalary; if (userSalary <= 2 * data) { graphFirst.percentage = Math.round((userSalary/ (2 * data)) * 100); GraphicData.getComparisonByIndustrySegment($scope.userInfo.jobStuff.subJobFamilyToSubmit.code, $scope.userInfo.jobStuff.gradeToSubmit, $scope.userInfo.jobStuff.industrySegmentToSubmit, userSalary, $scope.userInfo.jobStuff.location.localCoefficient, function(data){ generalGraphData.graphIndustry = data; console.log('this is the point right in the getComparisonByIndustrySegment function'); console.dir(data); GraphicData.getComparisonByExperinceYear($scope.userInfo.jobStuff.subJobFamilyToSubmit.code, $scope.userInfo.jobStuff.experienceToSubmit, $scope.userInfo.jobStuff.gradeToSubmit, $scope.userInfo.jobStuff.industrySegmentToSubmit, userSalary, $scope.userInfo.jobStuff.location.localCoefficient, function(data){ generalGraphData.graphExperience = data; GraphicData.getComparisonByCountry($scope.userInfo.jobStuff.location, userSalary, generalGraphData.averageSalary,function(data){ generalGraphData.graphCountry = data; GraphicData.getComparisonByCompanies($scope.userInfo.jobStuff.industrySegmentToSubmit.name, userSalary, generalGraphData.averageSalary, function(data){ generalGraphData.graphStates = data; (window.localStorage.setItem("userInfo", JSON.stringify($scope.userInfo))); (window.localStorage.setItem("generalGraphData", JSON.stringify(generalGraphData))); (window.localStorage.setItem("graphFirst", JSON.stringify(graphFirst))); Loading.hideLoading(); $ionicHistory.clearHistory(); $state.go('app.chart'); }); }); }); }); } }, function(){}); } } 它仍然这样做。顺便说一下我使用angular $ templateCache。它可以与它有什么关系吗?在此先感谢...这里有更多的代码

$stateProvider

          .state('app', {
            url: '/app',
            // abstract: true,
            templateUrl: 'app.html',
            controller: 'AppCtrl'
          })

          .state('app.login', {
            url: '/login',
            views: {
              'menuContent': {
                templateUrl: 'tab-signin.html',
                controller: 'LoginCtrl'
              }
            }
          })

          .state('app.signup', {
            url: '/signup',
            views: {
              'menuContent': {
                templateUrl: 'tab-signup.html',
                controller: 'LoginCtrl'
              }
            }
          })

          .state('app.formone', {
            url: '/formone',
            views: {
              'menuContent': {
                templateUrl: 'formone.html',
                controller: 'FormOneCtrl'
              }
            }
          })

          .state('app.mainform', {
            url: '/mainform',
            views: {
              'menuContent': {
                templateUrl: 'mainform.html',
                controller: 'MainFormCtrl'
              }
            }
          })

          .state('app.departments', {
            url: '/departments',
            views: {
              'menuContent': {
                templateUrl: 'departments-modal.html',
                controller: 'DepartmentsModalCtrl'
              }
            }
          })

          .state('app.industrysegment', {
            url: '/industrysegment',
            views: {
              'menuContent': {
                templateUrl: 'industrysegment-modal.html',
                controller: 'IndustrysegmentModalCtrl'
              }
            }
          })

          .state('app.jobfamily', {
            url: '/jobfamily',
            views: {
              'menuContent': {
                templateUrl: 'jobfamily-modal.html',
                controller: 'JobfamilyModalCtrl'
              }
            }
          })

          .state('app.profile', {
            url: '/profile',
            views: {
              'menuContent': {
                templateUrl: 'profile-page.html',
                controller: 'ProfileCtrl'
              }
            }
          })

          .state('app.mainformguest', {
            url: '/mainformguest',
            views: {
              'menuContent': {
                templateUrl: 'mainform-guest.html',
                controller: 'MainFormGuestCtrl'
              }
            }
          })

          .state('app.chart', {
            url: '/chart',
            views: {
              'menuContent': {
                templateUrl: 'chart.html',
                controller: 'ChartCtrl'
              }
            }
          })

          .state('app.chartguest', {
            url: '/chartguest',
            views: {
              'menuContent': {
                templateUrl: 'chart-guest.html',
                controller: 'ChartGuestCtrl'
              }
            }
          });

      $urlRouterProvider.otherwise('app/login');

这是提供者

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
  <link rel="manifest" href="manifest.json">

  <!-- build:css dist_css/styles.css -->
  <link href="css/ionic.app.min.css" rel="stylesheet">
  <!-- endbuild -->

  <script src="lib/ionic/js/ionic.bundle.js"></script>
  <script src="lib/ionic.cloud.min.js"></script>

  <script src="lib/jquery/jquery.min.js"></script>
  <script src="lib/jquery/jquery.focuspoint.min.js"></script>

  <!-- cordova script (this will be a 404 during development) -->
  <script src="lib/ngCordova/dist/ng-cordova.min.js"></script>
  <script src="cordova.js"></script>

  <script async src="lib/firebase/firebase.js"></script>
  <script defer src="http://maps.googleapis.com/maps/api/js?key=&amp;v=3.exp&amp;libraries=places&amp;language=en&amp;"></script>

  <!-- your app's js -->
  <!-- build:js dist_js/templates.js -->
  <script src="dist/dist_js/app/templates.js"></script>
  <!-- endbuild -->
  <!-- build:js dist_js/app.min.js -->
  <script src="js/app.js"></script>
  <script src="js/main.js"></script>
  <script src="js/controllers/controllers.js"></script>
  <script src="js/controllers/app-controller.js"></script>
  <script src="js/controllers/login-controller.js"></script>
  <script src="js/controllers/formone-controller.js"></script>
  <script src="js/controllers/profile-controller.js"></script>
  <script src="js/controllers/mainform-controller.js"></script>
  <script src="js/controllers/mainform-guest-controller.js"></script>
  <script src="js/controllers/chart-controller.js"></script>
  <script src="js/controllers/chart-guest-controller.js"></script>
  <script src="js/controllers/departments-modal-controller.js"></script>
  <script src="js/controllers/industrysegment-modal-controller.js"></script>
  <script src="js/controllers/jobfamily-modal-controller.js"></script>
  <!-- endbuild -->

</head>
<body ng-app="paytrends" ng-controller="AppCtrl" ng-strict-di>
<ion-nav-view></ion-nav-view>
</body>
</html>

这是我猜测的index.html相关部分。

{{1}}

0 个答案:

没有答案