2017-04-27 1 views
1

이것은 첫 번째 게시물입니다. 충분히 명확하고, $ state.go를 얻을 수 없기를 바랍니다. 대답을 찾으려면 너무 틀림없이 내가 뭘 잘못하고 있는지 알고 싶습니다. 왜냐하면 제가 생각하기에이 기술에 익숙하지 않기 때문입니다. 어쩌면 app.js에서 index.html을 선언해야하지만, 일단 앱이 시작되면이 페이지를 액세스 할 수 없도록해야합니다. 사용자가 로그인하면이 화면은 더 이상 보이지 않습니다. 앱을 다시 시작하십시오.

  1. 이이 내 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> 
    
  2. 내 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'); 
    }); 
    
  3. 입니다 그리고 이것은 내 controllers.js

    angular.module('starter.controllers', []) 
    
    .controller('loginCtrl', function($scope, $state) { 
    
        $scope.login = function() { 
        $state.go('tab.appointments'); 
        }; 
    }) 
    
입니다

미리 감사드립니다. 구문 오류가 있으면 사과드립니다. 편집

-이이 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을이 탭으로 리디렉션 하나가되는 무엇이다

    1. 을 추가했다. 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> 
      

    내가 index.html을에 home.html을의 이름을 변경하고 모든 것이 잘 작동에 사람들이 로그인 할 때 내가 원하는 실제 index.html을 사용하지 않는 경우,하지만 난 정말 필요 사람들은 로그인하여 자신의 기록을 갖습니다.

    This is what home.html actually looks like 내가 말했듯이, 나는 이런 종류의 기술에 익숙하지 않고, 이것이 어떻게 작동하는지 이해하려고 최선을 다하고 있습니다. 어떤 도움을 주셔서 감사합니다.

  • +0

    같이 변경 될 수 있습니다? 'templates/tabs.html'에도 '

    '이 있습니까? – Leguest

    +0

    필자는 ionic이 제공하는 템플릿을 수정했습니다. 어쨌든해야합니까? –

    +0

    또한,'templates/tabs.html'의'ui-view'는'tab-appointments'의 이름 속성을 가져야합니다. – Ladmerc

    답변

    1

    $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'; 
        }; 
    }) 
    
    +0

    실제로 이것은 트릭을 꽤 잘 만들어 주었고, 다른 페이지로 리디렉션되기 전에 입력 내용의 유효성을 검사 할 수도 있습니다 JS를 통해. 대답 해 주셔서 정말 고맙습니다. –

    관련 문제