创建Onsenui登录页面

时间:2016-01-26 11:54:38

标签: onsen-ui monaca

我正在尝试创建一个登录页面,如果用户未登录,则会重定向该用户。

在我的控制器中,我的控制器LoginController()中有一个pushPage('login.html'),但它似乎是在无限循环中重定向(即login.html页面只是保持重新加载而index.html出现在一个分数中一秒钟)不知道为什么..

的LoginController ()

app.controller('LoginController', ['$scope', '$http', function($scope,$http) {

   if(!checkLogin()) {
        myNavigator.pushPage('login.html');    
    }



    function checkLogin() {
        //temporariry return true;

        return false;
    }     
}]);

的index.html

<!DOCTYPE HTML>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' https://*.googleapis.com https://*.cloudflare.com 'unsafe-inline'; script-src 'self' http://*.phonegap.com https://*.googleapis.com https://*.cloudflare.com http://*.elasticbeanstalk.com https://*.monaca.mobi:8080 'unsafe-inline' 'unsafe-eval'">
    <link href='https://fonts.googleapis.com/css?family=Raleway:400,100,200,300,500,600,700,800,900' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>

    <script src="components/loader.js"></script>
    <script src="js/roundProgress.js"></script>
    <script>
       var app =  ons.bootstrap('app',  ['onsen','angular-svg-round-progress']);
    </script> 

    <script src="js/jquery.js"></script>
    <script src="js/cortisol.js"></script>
    <script src="js/circular.js"></script>
    <script src="js/settings.js"></script>
    <script src="js/checkLogin.js"></script>

    <link rel="stylesheet" href="components/loader.css">
    <link rel="stylesheet" href="css/style.css">
    <script src="js/jquery.sparkline.min.js"></script>

</head>
<body >

<ons-navigator var="myNavigator">
<ons-page ng-controller="LoginController">
    <ons-tabbar position="top">
      <ons-tabbar-item page="dashboard.html" style="margin-top:20px"><span style="margin-top:20px"><img src="img/icon.svg" width="34"/></span></ons-tabbar-item>
      <ons-tabbar-item page="dashboard.html"  icon="ion-ios-pulse-strong" active="true"  class="tab-bar__button tab-bar--top-border__button"></ons-tabbar-item>
      <ons-tabbar-item page="timeline.html"  icon="ion-android-calendar"></ons-tabbar-item>
      <ons-tabbar-item page="capture.html"  icon="ion-pinpoint"></ons-tabbar-item> 
      <ons-tabbar-item page="settings.html"  icon="ion-android-settings"></ons-tabbar-item>
    </ons-tabbar>
</ons-page>
</ons-navigator>
</body>

</html>

0 个答案:

没有答案