Saturday, November 25, 2017

Simple Login Example in AngularJS with form validations - Krazytech

Simple Login Example in AngularJS with form validations - Krazytech: This Simple Login Example in AngularJS concentrates on the authentication process, implementation and form validations. Visit to read more.



In our previous discussions, we have covered what is AngularJSbasic building blocksDependency Injectionand Routing in AngularJS. In this post, we are going to discuss how a login form works in AngularJS.
In this example, we have a simple login page. Whenever user provides username and password, they will be authenticated and redirected to a home page on success. If authentication fails, the user is notified with an error message.
Before we start implementing any application, it is a best practice to design the folder structure of an application so that anyone can easily understand it. Following is the directory structure for this Simple Login Example in AngularJS.
Directory structure for Simple Login Example in AngularJS
Directory structure
As we can see above, we have base shell index page, login page, its controller and same follows for the home page.
When the user enters his login credentials and clicks on login button, the request is authenticated in the loginService.js file and if authentication is successful, he will be redirected to the Home page. If authentication fails, he will be blocked on login page notifying with an error message and the user will be asked to enter correct credentials.
Suggested Read:
We have the main base page i.e. index.html where all other views are loaded accordingly. Following code explains the index page.

No comments:

Post a Comment