October 2017
Intermediate to advanced
458 pages
11h 13m
English
Now that we have the login page in place, we can actually connect to our backend, something we have not done yet! Basically, what we want is to log in and redirect to the shopping cart (which kind of serves as our personal page for this project). In the frontend, this is easy enough. We need to inject the $http module to our Angular controller that we can use to make an AJAX call. After that, we can call our backend and redirect on success or show an error when the user was not found:
$scope.login = function () { $scope.notFound = false; $http.post('/login', { username: $scope.username, password: $scope.password }).then(function (response) { if (response.data.success) { window.location.replace("/shopping-cart.html"); ...Read now
Unlock full access