Saturday, November 2, 2019

Generate Unique Identifiers In Angular Using UUID

1-open the terminal on your project path and run the following command

npm install uuid

2- at component class add the following code

import { v4 as uuid } from 'uuid';
unique :string;

  ngOnInit() {

    this.unique = uuid();

3- Display the unique reference on the component HTML using string interpolation

{{ unique }}

Enjoy !!

No comments:

Post a Comment