Skip to content

Instantly share code, notes, and snippets.

@SirajGadhia
Last active November 23, 2015 20:32
Show Gist options
  • Save SirajGadhia/e7fe196e41b9eb7d5d87 to your computer and use it in GitHub Desktop.
Save SirajGadhia/e7fe196e41b9eb7d5d87 to your computer and use it in GitHub Desktop.
AngularJS Controller Module (for Home) - www.Siraj360.com/ng/
//http://www.siraj360.com/ng/ :: A sample single page application (SPA) developed with AngularJS 1.4.5 and Bootstrap 3.3.5.
(function () {
//debugger;
"use strict;"
//Defination
angular.module('FD360').controller('HomeController',
['NoticeAndLogFactory', 'DataFactory', HomeController]);
function HomeController(NoticeAndLogFactory, DataFactory) {
// debugger;
var vm = this;
vm.AllEmployees = 0;
vm.AllCompleted = 0;
vm.AllPending = 0;
vm.AllCourses = 0;
init();
// all finctions
function init() {
getCourses();
getEmployees();
}
function getEmployees() {
//debugger;
var employees = DataFactory.getEmployees();
vm.AllEmployees = employees.length;
for (var i = 0; i < employees.length; i++) {
employees[i].isAllPending = true;
employees[i].isAllCompleted = true;
for (var j = 0; j < employees[i].EmployeeCourses.length; j++) {
if (employees[i].EmployeeCourses[j].isComplete) {
employees[i].isAllPending = false;
} else {
employees[i].isAllCompleted = false;
}
}
if (employees[i].isAllCompleted) {
vm.AllCompleted++;
}
if (employees[i].isAllPending){
vm.AllPending++;
}
}
}
function getCourses() {
var courses = DataFactory.getCourses();
vm.AllCourses = courses.length;
}
vm.toastr_test =
function () {
NoticeAndLogFactory.success("testing of factory", "got success", "log it");
NoticeAndLogFactory.error("testing of factory", "got error", "log it");
NoticeAndLogFactory.info("testing of factory", "got info", "log it");
NoticeAndLogFactory.warning("testing of factory", "got warning", "log it")
NoticeAndLogFactory.log("testing of factory", "simple log", "log it")
}
};
})();
//Download of full application at https://github.com/SirajGadhia/FD360-V2-AngularJS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment