Created
February 17, 2015 15:58
-
-
Save dyaa/a8020bbd6a2b43300b9c to your computer and use it in GitHub Desktop.
Using favico.js with AngularJS - Working demo is on http://lab.ejci.net/favico.js/example-angular/.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('app.controllers', ['favico.service']).controller('homeCtrl', ['$scope', 'favicoService', /** | |
* Home view controller | |
* @param {Object} $scope | |
*/ | |
function($scope, favicoService) { | |
//initial value | |
$scope.count = 3; | |
//badge +1 | |
$scope.plusOne = function() { | |
$scope.count = $scope.count + 1; | |
favicoService.badge($scope.count); | |
}; | |
//badge -1 | |
$scope.minusOne = function() { | |
$scope.count = ($scope.count - 1 < 0) ? 0 : ($scope.count - 1); | |
favicoService.badge($scope.count); | |
}; | |
//badge reset (count will be preserved) | |
$scope.reset = function() { | |
favicoService.reset(); | |
}; | |
//init value | |
favicoService.badge($scope.count); | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple favicon service | |
*/ | |
angular.module('favico.service', []).factory('favicoService', [ | |
function() { | |
var favico = new Favico({ | |
animation : 'fade' | |
}); | |
var badge = function(num) { | |
favico.badge(num); | |
}; | |
var reset = function() { | |
favico.reset(); | |
}; | |
return { | |
badge : badge, | |
reset : reset | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment