Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create GUID in angular-2?

Tags:

in my application i need to create GUID, that GUID will be work as cookies, so anybody knows how to create GUID in angular-2/typescript or using any angular2 dependency/library.

like image 592
Vinod Avatar asked Mar 14 '17 09:03

Vinod


1 Answers

You even can use npm to generate this for you. Follow this :

npm i guid-typescript --save 

And to utilize in your code :

import { Guid } from 'guid-typescript'; export class GuidExample {     public id: Guid;     constructor() {         this.id = Guid.create(); // ==> b77d409a-10cd-4a47-8e94-b0cd0ab50aa1     } } 
like image 98
Ali Eshghi Avatar answered Sep 30 '22 06:09

Ali Eshghi