如何在angularjs中从登录页面隐藏Heder

时间:2016-07-20 11:58:07

标签: html angularjs

我想隐藏登录页面中的标题。我的索引页面是

<!DOCTYPE html>
<html ng-app="myApp">
<head>
  <script src="angular.js"></script>
  <link rel="stylesheet" href="style.css" />
 <script src="script.js"></script>
</head>
<body ng-controller="CourseController">
<div class="row">
    <div class="col-lg-9">
            <div class="container-fluid" >

                <div class="row">
                    <div class="col-xs-12 col-lg-2">
                        <div class="main_logo"><img src="../app/image/track_logo.jpg" style="margin-top: 8px;" /> </div>
                    </div>
                    <div class="col-xs-12 col-lg-8">
                        <div class="navbar-header">
                            <span class="rsp_menu hidden-sm hidden-md hidden-lg" style="color:#fff; font-weight: bold; float: left; padding: 15px 14px;"> Menu</span>
                            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Menu</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
                        </div>
                        <div class="collapse navbar-collapse bk_menu" id="bs-example-navbar-collapse-1">
                            <ul class="nav navbar-nav" style="margin:0;">
                                <li class="dropdown mn_dp">
                                    <a href="#" class="dropdown-toggle">
                                        Student List  <b class="caret">
                                        </b>
                                    </a>
                                    <ul class="dropdown-menu">
                                        <!--<a ui-sref="Home" ID="Link_search" style="color:White;font-family:FangSong;font-size:15px;padding:8px;margin-left:7px;"
                                   Width="61px" Height="22px"
                                   ng-show="false">Activity</a>-->
                                        <li><a ui-sref="Candidate Registration">Create New</a></li>
                                        <li><a ui-sref="StudentList">Student List</a></li>
                                    </ul>
                                </li>
                                <li class="dropdown mn_dp">
                                    <a href="#" class="dropdown-toggle">
                                        Report <b class="caret">
                                        </b>
                                    </a>
                                    <ul class="dropdown-menu">
                                        <li><a ui-sref="Home1">Follow Up Report</a></li>
                                        <li><a ui-sref="Home1">Dashboard </a></li>
                                        <li><a ui-sref="Home1">Login Report</a></li>
                                    </ul>
                                </li>
                                <li class="dropdown mn_dp">
                                    <a href="#" class="dropdown-toggle">
                                        Settings <b class="caret">
                                        </b>
                                    </a>
                                    <ul class="dropdown-menu">
                                        <li><a ui-sref="Home1"> Country</a></li>
                                        <li><a ui-sref="Home1">Level </a></li>
                                        <li><a ui-sref="Home1">Department</a></li>
                                        <li><a ui-sref="Home1">Course</a></li>
                                    </ul>
                                </li>
                            </ul>
                        </div>
                    </div><div class="col-lg-2 bk_hd_rgt">
                        <p style="color:#fff;"><img src="../app/image/bk_admin.jpg"> {{uname}}</p>
                        <!--<p style="color:#fff;"> Name</p>-->
                        <p style="color:#fff;float:right"><a ui-sref="Authentication"><i class="fa fa-sign-out fa-fw"></i> Logout</a> </p>
                    </div>
                    {{uname}}
                </div>
            </div>

</div>

我的登录页面是

<div id="login" ng-controller="authController">
<form class="form-3 bgimg body" ng-keypress="checkIfEnterKeyWasPressed($event)">
     <p class="clearfix">
        &nbsp;
    </p>

    <p class="clearfix">
        &nbsp;
    </p>
    <br />
    <p class="clearfix">
        &nbsp;
    </p>
    <br />
    <center>
        <p class="clearfix">
            <input type="text" required="" id="login" ng-model="login" ng-minlength="1" ng-maxlength="30"
              placeholder="Username" size="50" autofocus />
        </p>
        <p class="clearfix">
           <input type="password" required="" ng-model="password" ng-minlength="1" ng-maxlength="30" id="password"
             placeholder="Password" size="50" ng-keypress="checkIfEnterKeyWasPressed($event)" />
        </p>
        <br />
        <button class="btn btn-success" id="btn_login" ng-click="submit()">Login</button>
        <button type="button" class="btn btn-danger" ng-click="cancel()">Cancel</button>
     </center>
</form>

我的控制器是

MyApp.controller('authController', function ($scope, $cookies, $state, $interval, $resource, $http, masterdataFactory) {
//console.log("Auth" + $rootScope); 
var Authentication;
sessionStorage.clear();
var Total;
var user;
var flagval;

$scope.login = $cookies.get('Uname');
$scope.password = $cookies.get('Password');
if ($scope.login != null) {
    $scope.rememberme = true;
    document.getElementById("btn_login").focus();

}

$scope.username = $scope.login;
$scope.Pswrd = $scope.password;
function IsAuthenticate(username, Pswrd) {
    debugger;
    masterdataFactory.IsAuthenticated(username, Pswrd)
        .success(function (data) {
            debugger;
            if (data.length !== 0) {

                sessionStorage.setItem("uname", $scope.login);
                $state.go('StudentList');
                if ($scope.rememberme == true) {
                    $cookies.put('Uname', $scope.login);
                    $cookies.put('Password', $scope.password);
                    $cookies.put('check', true)


                }
                else {
                    $cookies.remove('Uname');
                    $cookies.remove('Password');
                    $cookies.remove('check');
                }
            }
            else {
                if ($scope.login != null && $scope.password != null) {
                    toastr.error("Invalid User Name/Password");
                    $scope.login = null;
                    $scope.password = null;
                }


                $state.go('Authentication');

            }
            console.log($scope.courses)
        })
        .error(function (error) {
            $scope.status = 'Unable to load countries data: ' + error.message;
        });
}
$scope.checkIfEnterKeyWasPressed = function ($event) {


    var keyCode = $event.which || $event.keyCode;
    if (keyCode === 13) {
        if ($scope.login === "") {
            if ($scope.password == "") {
                $scope.login = null;
                $scope.password = null;
            }
        }

        if ($scope.login != "") {
            if ($scope.password != "") {
                flagval = 1;
            }
        }
       IsAuthenticate($scope.login, $scope.password);

    }

};

$scope.cancel = function () {
    $scope.login = "";
    $scope.password = "";
    document.getElementById("password").focus();
};
$scope.submit = function () {

    if ($scope.login === "") {
        if ($scope.password == "") {
            $scope.login = null;
            $scope.password = null;
        }
    }

    if ($scope.login != "") {
        if ($scope.password != "") {
            flagval = 1;
        }
    }
    IsAuthenticate($scope.login, $scope.password);
  };
 });

我想隐藏登录页面的标题。显示用户名opther页面。如何运作任何人都可以帮助我?

2 个答案:

答案 0 :(得分:0)

在要登录的标题上放置一个nv-hide =“varaibleName”/ nv-show =“variableName”在登录部分。让登录按钮/ etc有一个函数可以反转变量的值/从真/假等改变它。

答案 1 :(得分:0)

使用nv-hide会隐藏标题,使其占用的空间被阻止。你可以说它会使标题&#34; Invisible&#34;。

您可以编写一个函数来添加或删除该类。

这样的事情:

case "/page/500": return a.addClass("body-wide body-err");