4

I'd like to set a login page before entering the main page. How can I do that just before this instruction :

<ons-screen page="sliding_menu.html"></ons-screen>

I use The Monaca IDE

Thanks for the help

Charles

Andi Pavllo
  • 2,506
  • 4
  • 18
  • 30
charlesen
  • 65
  • 1
  • 7

1 Answers1

11

You can try this way:

index.html

<ons-screen page="login.html"

login.js

function LoginController($scope){
    $scope.login = function(id, password){
        $scope.ons.screen.presentPage('sliding_menu.html');
    }
}

login.html

    <div class="page center" ng-controller="LoginController">
    <div class="row">
        <div class="col">
            <ons-text-input placeholder="id" ng-model="id">             
            </ons-text-input>
        </div>
    </div>
    <div class="row">
        <div class="col">
            <input type="password" placeholder="password" ng-model="password" class="topcoat-text-input">
        </div>
    </div>

    <div class="row">
        <div class="col">
            <ons-button ng-click="login(id, password)">
                Login
            </ons-button>
        </div>
    </div>
</div>

Demo: http://onsenui.github.io/stackoverflow/sliding_menu_login/app/

Download src: http://onsenui.github.io/stackoverflow/sliding_menu_login.zip

Tamura
  • 1,788
  • 1
  • 14
  • 10