use promis with date angular 1

use promis with date angular

lastUpdate: Promise = new Promise(
  (resolve, reject) => {
    const date = new Date();
    setTimeout(
      () => {
        resolve(date);
      }, 2000
    );
  }
);

Here is what the above code is Doing:
1. We create a new Promise object.
2. We pass a function to the Promise object.
3. The function takes two arguments: resolve and reject.
4. We create a new Date object.
5. We use setTimeout to call resolve after 2 seconds.
6. We pass the date object to resolve.

Similar Posts