Angularjs IONAL v1$state.go不工作

Angularjs IONAL v1$state.go不工作,angularjs,cordova,ionic-framework,Angularjs,Cordova,Ionic Framework,这是我的第一篇帖子,我希望我足够清楚,我不能得到$state。去工作吧,我一直在搜索,但我似乎没有找到答案,我不太确定我做错了什么,因为我对这项技术很陌生,我认为这项技术真的很好。也许我必须在app.js中声明index.html,但我不希望在应用启动后访问此页面,仅在开始时,一旦用户登录,除非他们重新启动应用,否则将无法再看到此屏幕 这是我的app.js angular.module('starter', ['ionic','starter.controllers', 'starter.ser

这是我的第一篇帖子,我希望我足够清楚,我不能得到$state。去工作吧,我一直在搜索,但我似乎没有找到答案,我不太确定我做错了什么,因为我对这项技术很陌生,我认为这项技术真的很好。也许我必须在app.js中声明index.html,但我不希望在应用启动后访问此页面,仅在开始时,一旦用户登录,除非他们重新启动应用,否则将无法再看到此屏幕

  • 这是我的app.js

    angular.module('starter', ['ionic','starter.controllers', 'starter.services'])
    
    .config(function($ionicConfigProvider, $stateProvider, $urlRouterProvider) {
    
    $stateProvider
    
    .state('tab', {
     url: '/tab',
     abstract: true,
     templateUrl: 'templates/tabs.html'
    })
    
    .state('tab.appointments', {
     url: '/appointments',
     views: {
      'tab-appointments': {
        templateUrl: 'templates/tab-appointments.html',
        controller: 'appointmentsCtrl'
      }
     }
    })
    
    .state('tab.findPatient', {
     url: '/findPatient',
     views: {
      'tab-findPatient': {
       templateUrl: 'templates/tab-findPatient.html',
       controller: 'FindPatientCtrl'
      }
     }
    }) 
    
    .state('tab.findSlot', {
     url: '/findSlot',
     views: {
      'tab-findPatient': {
       templateUrl: 'templates/tab-findSlot.html',
       controller: 'FindPatientCtrl'
       }
      }
    })
    
    .state('tab.settings', {
     url: '/settings',
     views: {
      'tab-settings': {
       templateUrl: 'templates/tab-settings.html',
       controller: 'settingsCtrl'
       }
     }
    });
    
    $urlRouterProvider.otherwise('/tab/appointments');
    });
    
  • 这是我的index.html

     <body ng-app="starter">
     <ion-header-bar class="bar-calm" align-title="center"></ion-header-bar>
     <ion-pane>
      <ion-content scroll="false">
       <form ng-controller="loginCtrl" name="loginCredentialsForm">
        <div class="list list-inset">
         <label class="item item-input">
          <input class="text-center" type="text" placeholder="Username" ng-model="username" required="true">
         </label>
         <label class="item item-input">
          <input class="text-center" type="password" placeholder="Password" ng-model="password" required="true">
         </label>
         <label class="item item-input">
          <input class="text-center" type="password" maxlength=4 placeholder="PIN" ng-model="practicePin" required="true">
         </label>
        </div>
        <div class="text-center">
          <button class="button button-block button-calm small_button" ng-disabled="loginCredentialsForm.$invalid" ng-click="login()" type="submit">Login</button>
        </div>
       </form>
      </ion-content>
     </ion-pane>
     </body>
    
  • 提前谢谢,我为任何语法错误道歉

    编辑-添加

  • 这就是tabs.html的外观

    <ion-tabs class="tabs-icon-bottom tabs-calm">
      <ion-tab title="Appointments" icon-off="ion-ios-pulse" icon-on="ion-ios-pulse-strong" href="#/tab/appointments">
      <ion-nav-view name="tab-appointments">
      </ion-nav-view>
      </ion-tab>
    </ion-tabs>
    
    
    
  • 还有home.html,我敢肯定它是一个重定向到tabs.html,然后由其他人加载的

       <body ng-app="starter">
        <ion-nav-bar class="bar-calm" align-title="center">
          <ion-nav-back-button>
          </ion-nav-back-button>
        </ion-nav-bar>
        <ion-nav-view></ion-nav-view>
       </body>
    
    
    
  • 如果我将home.html的名称改为index.html,并且不使用我希望人们登录的实际index.html,那么一切都可以正常工作,但我确实需要人们登录,以便他们有自己的记录


    正如我所说的,我对这类技术还不熟悉,我试图尽我所能去理解它是如何工作的。非常感谢您的帮助。

    您也可以使用
    $window
    重定向到页面

     $window.location.href = 'templates/tab-appointments.html'; 
    
    您的控制器可以这样更改

    angular.module('starter.controllers', [])
    
     .controller('loginCtrl', function($scope, $state,$window) {
    
       $scope.login = function() {
        $window.location.href = 'templates/tab-appointments.html'; 
      };
    })
    

    开发人员工具控制台中是否有错误?在
    templates/tabs.html
    中也有“”吗?我刚刚修改了ionic给出的模板作为示例,我应该这样做吗?此外,
    templates/tabs.html
    中的
    ui视图
    应该有一个名称属性
    tab appointments
    ,这实际上使技巧非常好,您甚至可以在通过JS重定向到其他页面之前验证输入。我真的很感激你的回答
    angular.module('starter.controllers', [])
    
     .controller('loginCtrl', function($scope, $state,$window) {
    
       $scope.login = function() {
        $window.location.href = 'templates/tab-appointments.html'; 
      };
    })