Welcome to the login page
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<title>Login Page</title>
</head>
<body>
<div class="container" ng-controller="loginctrl">
<h1>Login Page</h1>
<label>UserName</label><input class="form-control" ng-model="user.name"><br><br>
<label>Password</label><input class="form-control" ng-model="user.password"><br><br>
<button class="btn btn-primary" ng-click="login()" >Login</button>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
<script src="controllers/logincontroller.js"></script>
<script src="angularjs/angular.js"></script>
<script src="angular-route/angular-route.js"></script>
</body>
</html>
This is Controller page
var myapp = angular.module('myApp', ['ngRoute']);
myapp.config(["$routeProvider", function($routeProvider) {
$routeProvider
.when('/', {
controller: 'loginctrl',
templateUrl: 'login.html'
})
.when('/addusers', {
controller: 'addusersctrl',
templateUrl: 'addusers.html'
})
.otherwise({
redirectTo: '/'
});
}]);
myapp.controller('loginctrl',['$scope', '$route', '$routeParams', '$location',function($scope,$http,$location){
console.log("I am a controller");
$scope.login = function() {
// $http.post('/login',$scope.user).success(function(response){
$http({
method: 'post',
url: '/login',
data: $scope.user
}).then(function successCallback(response) {
console.log(response.data);
$location.path("/addusers");
}, function errorCallback(response) {
console.log(response.data);
});
};
}]);
myapp.controller('addusersctrl',['$scope','$http',function($scope,$http){
console.log("I am a controller");
$scope.login = function() {
// $http.post('/login',$scope.user).success(function(response){
$http({
method: 'post',
url: '/login',
data: $scope.user
}).then(function successCallback(response) {
console.log(response.data);
}, function errorCallback(response) {
console.log(response.data);
});
};
}]);
I keep encountering this error whenever I attempt to run this code:
Angular.js error angular.js:38 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.6.1/$injector/modulerr?p0=myApp&p1=Error%3A%2…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.6.1%2Fangular.min.js%3A21%3A332)