I am currently developing an application using Angular.js and I find myself a little confused about utilizing Angular to build it.
Below, you will see a preview of what I have so far - it may not look great, but it functions.
I believe there are more effective ways to accomplish this task, and I would appreciate input from other users considering the following:
The application will: 1) gather inputs across 8 steps 2) based on those inputs, display specific results 3) allow users to navigate to any state at any time
// Setting up an application module
var app = angular.module('website', ['ngSanitize','ngAnimate','ui.router']);
app.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/home");
$stateProvider
.state('home', {
url: "/home",
templateUrl: "js/partials/home.html",
controller: HomeCtrl
})
// Additional states for step-by-step process...
});
// Function to calculate new percentage value based on step
function getNewPercentageValue(step, percent){
var NewPercentage = 0;
if(percent){
NewPercentage = percent * step;
}else{
$rootScope.values.ActualPercentage = (100/8);
NewPercentage = $rootScope.values.ActualPercentage * step;
}
return NewPercentage;
}
// Controller for Home page
function HomeCtrl($scope, $http, $rootScope, $state) {
/* DEFAULT VARIABLES */
$rootScope.values = {
ActualPercentageSteps: (100/8),
ActualPercentage: 0
};
}
// Controllers for each step in the process...