Hi

I am creating a webapp authentication using perl at backend and AngularJS 
at frontend. http.get is returning a valid result from the backend but I am 
not sure how to redirect to home.html after succesfull authentication 
received from the API

#### Index,html

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <title>TarView Login</title>

    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="css/bootstrap.min.css">

    <link rel="stylesheet" href="css/prod/styles.css">

    <script src="ajs/lib/angular.min.js"></script>

</head>



<body ng-app="TarView">



<div ng-controller="LoginController" >

    <form ng-submit="loginForm.submit()">

        <input type="text" name="username" value="" placeholder="Username" 
ng-model="loginForm.username" required><br/>

        <input type="password" name="password"  value="" placeholder = 
"Password" ng-model="loginForm.password" required><br/>



            <!-- button type="submit" id="login" class="btn 
btn-primary">Login</button-->

<button type="submit" id="submit" class="btn btn-primary">Login</button>

            <!-- a href="#/register" class="btn btn-link">Register</a> -->

</form>


  <script src="ajs/app/app.js"></script>

</div>

</body>

</html>

### app.js #####

var app = angular.module("TarView", []);

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

                $scope.authData = []; // This will receive the data from 
the backend

                $scope.loginForm = {};

                $scope.loginForm.username = "";

                $scope.logiForm.password  = "";

/*

 * submit function will send the Ajax request to the server and get the 
valid username and password

 * for the value entered by the user.

 * NOTE:- The value returned from the Perl API should be JSON format.

 */

                $scope.submit = function() {

                  $scope.names = {};

                  
$http.get("http://localhost:5000/login/username/password";).

                  success(function (response) {

                      $scope.names = response.user;

                    })

                };
            }]);
#######
RestAPI is returning in the format 

{"user":{"Name":"Ashutosh","Flag":"True"}}

If flag is True then app should redirect to home.html

######
is there any redirect() function in anglarJS ? Do I have to app.service or 
app.factor or injection mechanism ???

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to