当用户不在主页上时显示后退按钮

时间:2016-07-05 17:50:58

标签: javascript html angularjs ionic-framework

当用户从主页移动到登录后,用户无法在标题顶部找到后退按钮

    .config(function($stateProvider, $urlRouterProvider,$ionicConfigProvider){
    $ionicConfigProvider.tabs.position("standard");
    $ionicConfigProvider.tabs.style("standard");
        $stateProvider
        .state('tabs',{
            url: '/tab',
            abstract:true,
            templateUrl:'templates/index_tabs.html',

        })



         .state('tabs.index',{
            url:'/index',
            views:{
            'list-index':{
            templateUrl:  'templates/index_files/index.html',
            }
            }
        })

        .state('tabs.login',{
            url:'/login',
            views:{
            'list-login':{
            templateUrl:  'templates/index_files/login.html',
            }
            }
        })

$urlRouterProvider.otherwise('/tab/index')
     })

的login.html

<ion-header-bar class="bar-positive" align-title="center">
      <h1 class="title">Sign In</h1>
          </ion-header-bar>

          <ion-view>
          <ion-content>
          <div ng-app="starter" ng-controller="userlogin_controller">
            <form id="login_form" name="login_form" method="post" action="">
              <div class="list list-inset">
                <div class="list modal">
                  <label class="item item-input item-stacked-label">
                  <span class="input-label">Email</span>

                  <input name="email" type="email" id="email" placeholder="someone@example.com" ng-model="userlogin.email" required="required" autocomplete="off"/>

                  <div class="error" ng-show="login_form.email.$error.email">Email is not valid</div>


                  </label>
                  <label class="item item-input item-stacked-label"> <span class="input-label">Password</span>
                    <input name="password" type="password" id="password" placeholder="Enter password here" ng-model="userlogin.password" />
                  </label>
                  </br>
                  <p align="center">
                    <button ng-disabled="login_form.$invalid" class="button button-positive" ng-click="userlogin()"> Go viva</button>
                  </p>
                  </br>
                  <p align="center"><a href="#/tab/forgotpassword">Forgot your password?</a></p>

                  <p align="center"><button class="icon icon-left ion-social-facebook button button-positive button-small" ng-click="facebookSignIn()">Sign Up with Facebook</button></p>
                </div>
              </div>
              </div>
            </form>

          </ion-content>

          </ion-view>

的index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>

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

    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/services.js"></script>
    <script src="cordova.js"></script>
    <script src="js/ng-cordova.js"></script>

  </head>

  <body ng-app="starter">

      <ion-nav-bar class="bar-positive">
  <ion-nav-back-button class="button-clear">
     Back
  </ion-nav-back-button>
</ion-nav-bar>

      <ion-nav-view>

      </ion-nav-view>

  </body>
</html>

有关如何在用户离开主页时显示后退按钮的帮助吗?

1 个答案:

答案 0 :(得分:0)

尝试使用这些代码替换您的login.html页面

$("#login").click(function (event) { event.preventDefault(); if($("#username").val()=="") { $("#usernamenull").html("username required <br />"); return false; } else if($("#password").val()=="") { $("#passwordnull").html("password required <br />"); return false; } var xhra=$.post("login.php",{username:$("#username").val(),password:$("#password").val()}); xhra.done(function (data) { if (data==0) { $("#message").html("username or password incorrect.<br />"); } else if (data==1) { $("#message").html("good.<br />"); $("#login").submit(); } }); xhra.fail(function () { alert("oops : "+xhra.status+" "+xhra.statusText+".\n"); }); }) };