Commit e9fc20c7009f9ca0d08253061827ad34b7b18226
1 parent
c446582a
Exists in
master
and in
8 other branches
Add new service: GUID
Showing
1 changed file
with
24 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
1 | +(function() { | ||
2 | + 'use strict'; | ||
3 | + | ||
4 | + angular | ||
5 | + .module('dialoga') | ||
6 | + .factory('GUID', GUID); | ||
7 | + | ||
8 | + /** @ngInject */ | ||
9 | + function GUID(){ | ||
10 | + var service = {}; | ||
11 | + | ||
12 | + service.generate = function (){ | ||
13 | + function s4() { | ||
14 | + return Math.floor((1 + Math.random()) * 0x10000) | ||
15 | + .toString(16) | ||
16 | + .substring(1); | ||
17 | + } | ||
18 | + return s4() + s4() + '-' + s4() + '-' + s4() + '-' + | ||
19 | + s4() + '-' + s4() + s4() + s4(); | ||
20 | + } | ||
21 | + | ||
22 | + return service; | ||
23 | + } | ||
24 | +})(); |