如何使用angularjs ng-route重定向到其他html页面

时间:2016-01-19 12:51:00

标签: angularjs

当我点击signUp.html页面中的signUp按钮时,它应该重定向到signIn.html页面。但是我无法重定向到signIn.html页面。任何人都可以帮我解决这个问题... < / p>

我的signIn.html:

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/custom.css" />
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/angular.min.js"></script>
<script src="js/angular-animate.min.js"></script>
<script src="js/angular-route.min.js"></script>

</head>
<body>
    <div class="container" id="wrapper" align="center">
        <div>
            <img id="imgDiv" src="images/favicon.png">
        </div>
        <div id="loginDiv">
            <h3>LogIn</h3>
            <form>
                <input type="text" class="resizedTextbox" ng-model="email"
                    placeholder="Email" /><br> <br> <input type="password"
                    class="resizedTextbox" ng-model="password" placeholder="Password" /><br>
                <br> <input type="submit" class="resizedBtn" value="LogIn">
                <div id="signUpDiv">
                    Not a member yet? <a href="html/signUp.html">SignUp Now</a>
                </div>
            </form>
        </div>
    </div>
</body>

我的signUp.html:

<html ng-app="Sample">
<head>
<link rel="stylesheet" href="../css/bootstrap.min.css" />
<link rel="stylesheet" href="../css/custom.css" />
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/angular.min.js"></script>
<script src="../js/angular-animate.min.js"></script>
<script src="../js/angular-route.min.js"></script>
<script src="../js/script.js"></script>

</head>
<body>
    <div class="container" id="wrapper1" align="center">
        <div>
            <img id="logoDiv" src="../images/favicon.png">
        </div>
        <div id="loginDiv">
            <h3>Sign up</h3>
            <form>
                <input type="text" class="resizedTextbox" ng-model="email" placeholder="Email" /><br> <br>
                <input type="text" class="resizedTextbox" placeholder="Password" /><br><br> 
                 <input type="text" class="resizedTextbox" placeholder="Verify Password" /><br><br> 
               <a href="#/signUp"> <button class="resizedBtn" value="SIGN UP">SignUp
                </button></a>
            </form>
        </div>
    </div>

</body>
</html>

我的script.js:

var app = angular.module('Sample', [ 'ngRoute' ]);
app.config([ '$routeProvider', function($routeProvider) {
    $routeProvider.when('/signUp', {
        // controller :'signUpController',
        templateUrl : '../signIn.html'
    })

} ]);

1 个答案:

答案 0 :(得分:1)

注册成功后使用此功能。

 $location.path('/signinpath');

为此,您需要注入$location服务