Wizard form
Have you seen a wizard form? I am sure you have. I think the usage of it is very common these days. I like it very much, too. I think its structure is extremely user-friendly, because it can help us to avoid discouraging users from filling the form with all data. As a user I don’t want to be pushed to fill long forms. It’s annoying. But while you use the wizard no matter how long the form is, firstly you can quickly see the progress of you work and then, don’t see it at once, just fill one field at a time.
That’s the result why have I decided to use it in CommonsNet project, too.
Angular JS
To implement this on CommonsNet website I have decided to use AngularJS which makes it easy.
I have used Model View Controller which is a software design pattern for developing web applications. A Model View Controller pattern is made up of the following three parts
Model − It is the lowest level of the pattern responsible for maintaining data
View − It is responsible for displaying all or a portion of the data to the user
Controller − It is a software Code that controls the interactions between the Model and View.
This model helps us to isolate the application logic from the user interface layer and supports separation of concerns.
The ng-controller directive defines the application controller. A controller is a JavaScript Object
Steps to create AngularJS app
1. Load AngularJS on your webiste.
src = "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js">
2. Define AngularJS app using ng-app.
<body ng-app = "app"> ... </body>
3. Then I have created views – five different html files for each wizard step. Please take a look at partials folder where you can find them.
4. Next, I have created a .Controller – WizardController in AngularJS.
var WizardController = app.controller("WizardController", function ($scope) { // controller logic goes here } );
It is a JavaScript function. I have defined which view has to be displayed by .controller on each step. As you can see it’s quite easy and clear. You can quickly define and see which step is it , how is its name and which template should be used. It definitely enables you to maintain your app easier, because changes can be made quickly and does not influence on other part of code so you can take control over your code.
5. Then I have used this line of code to call to my WizardController to display and maintain my views and that’s it. See the progress on CommonsNet
<div id="wizard-container" ng-controller="WizardController as vm">
You must be logged in to post a comment.