Skip to content

Instantly share code, notes, and snippets.

@SirajGadhia
Created November 23, 2015 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SirajGadhia/94fc540626b54ef44fc1 to your computer and use it in GitHub Desktop.
Save SirajGadhia/94fc540626b54ef44fc1 to your computer and use it in GitHub Desktop.
AngularJS Filter Module - 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 () {
//define filter module
angular.module('Filter360', []);
// 1 - Clculate %
angular.module('Filter360').filter('percentage', ['$filter', percentage]);
function percentage($filter) {
return function (input, decimals) {
//debugger;
return $filter('number')(input * 100, decimals) + '%';
};
};
// 2 - Image Check Mark
angular.module('Filter360').filter('imagecheckmark', imagecheckmark);
function imagecheckmark() {
return function (is_true) {
return is_true ? '<span class="glyphicon glyphicon-ok"></span>' : '<span class="glyphicon glyphicon-remove"></span>';
}
}
// 3 - CSS Class Switch for Cource table row color change
angular.module('Filter360').filter('courserowclass', courserowclass);
function courserowclass() {
return function (is_true) {
return is_true ? 'success' : 'default';
}
}
// 4 - CSS Class Switch for Employe Table Header color change
angular.module('Filter360').filter('employeeheaderclass', employeeheaderclass);
function employeeheaderclass() {
return function (total, completed) {
var _class = 'panel panel-info'
if (completed == total) {
_class = 'panel panel-success'
}
if (completed == 0) {
_class = 'panel panel-danger'
}
return _class;
}
}
})();
//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