I am new to Angular JS and was wanting to start with the login form. I read a few online materials and decided to give it a go.
Below is my code, and when I click "Login", nothing happens, I am not sure if my html script talks to the controller or did I code something wrong in controller.
<!DOCTYPE html>
<html data-ng-app="loginAuth">
<head>
<title>
</title>
</head>
<body>
<h2>Angular Authentication</h2>
<div data-ng-controller="loginController">
<label>Username</label>
<input type="text" name="username" data-ng-model="login.username"/>
<br/>
<label>Password</label>
<input type="password" name="password" data-ng-model="login.password"/>
<br/>
<input type="button" ng-submit="login.submit(login.username, login.password)" value="Login"/>
<br/><br/>
{{login.message}}
</div>
<script src="angular.min.js"></script>
<script>
'use strict';
angular.module('loginAuth')
.controller('loginController', function ($scope)
{
function login.submit(username, password)
{
if (username === 'admin' && password === 'test99')
{
.then(onSuccess);
}
else
{
.catch(onError);
}
}
function onSuccess()
{
login.message = 'Login Successful!';
}
function onError(reason)
{
login.message = reason.message;
}
});
</script>
</body>
</html>
Can someone please help me out.